﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;

using CE.Mail;
using CE.Image;
using CE.Global;
using CE.Database;
using CE.CreditCard;
using CE.User;
using CE.PostCode;
using CE.CarInsurance;
using CE.Provider;
using CE.Security;
using CE.InputOut;
using CE.StreetDirectory;
using CE.Payment;

public partial class car_Insurance_new_proposalforms_hsbc_proposal_form : System.Web.UI.Page
{
    public static Int64 _CarId, _CarMoreId, _UserId, _CXCTypeId, _ProviderId;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.UserTypeId] != null)
        {
            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                 Convert.ToInt32(CE.Global.CEUserType.Customer) && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                 Convert.ToInt32(CE.Global.CEUserType.Provider))
            {
                Response.Redirect("~/car-insurance/login.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/login.aspx");
        }

        if (Session[General.CarId] == null || Session[General.CarPolicyId] == null)
        {
            Response.Redirect("~/car-insurance/profile.aspx");
        }

        if (Session[CE.Global.General.CarResultId] != null)
        {
            if (Session[General.ProviderCompanyId].ToString() != "23")
            {
                Response.Redirect("~/user/viewresulthistory.aspx");
            }
        }
        else
        {
            Response.Redirect("~/user/viewresulthistory.aspx");
        }
         

        if (!IsPostBack)
        {
            //if (!CheckCarQuoteUpdateStatus())
            //{
            //    Response.Redirect("profile.aspx");
            //}

            //ibtSubmit.Attributes.Add("onclick", "return confirm('By pressing the submit button, you authorise CompareXpress to send your personal information to the partipating merchant of your choice. You therefore exempt CompareXpress from any liability relating to the sharing of this information with our participating merchant.');");
            //ibtSubmit.Attributes.Add("OnClick", "javascript:if (Page_ClientValidate('proposal')) { return confirm('By pressing the submit button, you authorise CompareXpress to send your personal information to the partipating merchant of your choice. You therefore exempt CompareXpress from any liability relating to the sharing of this information with our participating merchant.'); } return false;");

            lblDisclaimer.Text = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCarProposalDisclaimer");
            #region Load Combo

            InsurerDB _insurerdb = new InsurerDB();

            DataTable dtPreInsurerComp = _insurerdb.GetPreInsurer(100, 1);
            ddlTransInsuranceCompany.DataSource = dtPreInsurerComp;
            ddlTransInsuranceCompany.DataTextField = dtPreInsurerComp.Columns[0].ColumnName.ToString();
            ddlTransInsuranceCompany.DataValueField = dtPreInsurerComp.Columns[1].ColumnName.ToString();
            ddlTransInsuranceCompany.DataBind();
            ddlTransInsuranceCompany.Items.Insert(0, new ListItem("Not Applicable", "0"));
            ddlTransInsuranceCompany.Items.Insert(0, new ListItem("Select", "-1"));

            DataTable dtPreInsurerBank = _insurerdb.GetPreInsurer(100, 2);
            ddlHirePurchaseCompany.DataSource = dtPreInsurerBank;
            ddlHirePurchaseCompany.DataTextField = dtPreInsurerBank.Columns[0].ColumnName.ToString();
            ddlHirePurchaseCompany.DataValueField = dtPreInsurerBank.Columns[1].ColumnName.ToString();
            ddlHirePurchaseCompany.DataBind();
            ddlHirePurchaseCompany.Items.Insert(0, new ListItem("Select", "-1"));

            int _year;
            int startyear = CE.Global.General.GetUTCDateTime().Year;
            int endyear = CE.Global.General.GetUTCDateTime().Year + 10;
            for (_year = endyear; _year >= startyear; _year--)
            {
                ddlCardExpiryYear.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("00")));
            }
            ddlCardExpiryYear.Items.Insert(0, new ListItem("yyyy", "-1"));


            int startacciyear = CE.Global.General.GetUTCDateTime().Year - 3;
            int endacciyear = CE.Global.General.GetUTCDateTime().Year;

            ddlDateofAccident.StartYear = startacciyear;
            ddlDateofAccident.EndYear = endacciyear;
            ddlDateofAccidentDriver1.StartYear = startacciyear;
            ddlDateofAccidentDriver1.EndYear = endacciyear;
            ddlDateofAccidentDriver2.StartYear = startacciyear;
            ddlDateofAccidentDriver2.EndYear = endacciyear;
            ddlDateofAccidentDriver3.StartYear = startacciyear;
            ddlDateofAccidentDriver3.EndYear = endacciyear;
            ddlDateofAccidentDriver4.StartYear = startacciyear;
            ddlDateofAccidentDriver4.EndYear = endacciyear;
            ddlDateofAccidentDriver5.StartYear = startacciyear;
            ddlDateofAccidentDriver5.EndYear = endacciyear;

            int _lryear;
            int startlryear = CE.Global.General.GetUTCDateTime().Year;
            int endlryear = CE.Global.General.GetUTCDateTime().Year - 50;
            for (_lryear = endlryear; _lryear <= startlryear; _lryear++)
            {
                ddlYearofRevoked.Items.Insert(0, new ListItem(_lryear.ToString("0000"), _lryear.ToString("0000")));
                ddlYearofRevokedDriver1.Items.Insert(0, new ListItem(_lryear.ToString("0000"), _lryear.ToString("0000")));
                ddlYearofRevokedDriver2.Items.Insert(0, new ListItem(_lryear.ToString("0000"), _lryear.ToString("0000")));
                ddlYearofRevokedDriver3.Items.Insert(0, new ListItem(_lryear.ToString("0000"), _lryear.ToString("0000")));
                ddlYearofRevokedDriver4.Items.Insert(0, new ListItem(_lryear.ToString("0000"), _lryear.ToString("0000")));
                ddlYearofRevokedDriver5.Items.Insert(0, new ListItem(_lryear.ToString("0000"), _lryear.ToString("0000")));
            }
            ddlYearofRevoked.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofRevokedDriver1.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofRevokedDriver2.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofRevokedDriver3.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofRevokedDriver4.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofRevokedDriver5.Items.Insert(0, new ListItem("yyyy", "-1"));

            int _obtyear;
            //int startobtyear = CE.Global.General.GetUTCDateTime().Year - 18;
            int startobtyear = CE.Global.General.GetUTCDateTime().Year;
            int endobtyear = CE.Global.General.GetUTCDateTime().Year - 60;
            for (_obtyear = endobtyear; _obtyear <= startobtyear; _obtyear++)
            {
                ddlYearofObtained.Items.Insert(0, new ListItem(_obtyear.ToString("0000"), _obtyear.ToString("0000")));
                ddlYearofObtainedDriver1.Items.Insert(0, new ListItem(_obtyear.ToString("0000"), _obtyear.ToString("0000")));
                ddlYearofObtainedDriver2.Items.Insert(0, new ListItem(_obtyear.ToString("0000"), _obtyear.ToString("0000")));
                ddlYearofObtainedDriver3.Items.Insert(0, new ListItem(_obtyear.ToString("0000"), _obtyear.ToString("0000")));
                ddlYearofObtainedDriver4.Items.Insert(0, new ListItem(_obtyear.ToString("0000"), _obtyear.ToString("0000")));
                ddlYearofObtainedDriver5.Items.Insert(0, new ListItem(_obtyear.ToString("0000"), _obtyear.ToString("0000")));
            }
            ddlYearofObtained.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofObtainedDriver1.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofObtainedDriver2.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofObtainedDriver3.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofObtainedDriver4.Items.Insert(0, new ListItem("yyyy", "-1"));
            ddlYearofObtainedDriver5.Items.Insert(0, new ListItem("yyyy", "-1"));

            #endregion

            #region Validation Effect

            txtFamilyName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtFamilyName.ClientID + "','" + rfvFamilyName.ClientID + "','" + revFamilyName.ClientID + "')");
            txtGivenName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtGivenName.ClientID + "','" + rfvGivenName.ClientID + "','" + revGivenName.ClientID + "')");
            ddlRace.Attributes.Add("onblur", "ShowValidationEffect('" + ddlRace.ClientID + "','" + rfvRace.ClientID + "')");
            txtPostCode.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtPostCode.ClientID + "','" + rfvPostCode.ClientID + "','" + revPostCode.ClientID + "')");
            txtUnit1.Attributes.Add("onblur", "ShowValidationEffect('" + txtUnit1.ClientID + "','" + rfvUnit1.ClientID + "')");
            txtUnit2.Attributes.Add("onblur", "ShowValidationEffect('" + txtUnit2.ClientID + "','" + rfvUnit2.ClientID + "')");
            txtAddress.Attributes.Add("onblur", "ShowValidationEffect('" + txtAddress.ClientID + "','" + rfvAddress.ClientID + "')");
            //txtEmpName.Attributes.Add("onblur", "ShowValidationEffect('" + txtEmpName.ClientID + "','" + revEmpName.ClientID + "')");
            ddlTransInsuranceCompany.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTransInsuranceCompany.ClientID + "','" + rfvTransInsuranceCompany.ClientID + "')");
            //txtTransInsVehicleNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtTransInsVehicleNo.ClientID + "','" + rfvTransInsVehicleNo.ClientID + "')");
            txtNCDReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtNCDReason.ClientID + "','" + rfvNCDReason.ClientID + "')");
            txtVehicleNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtVehicleNo.ClientID + "','" + rfvVehicleNo.ClientID + "')");
            ddlEngineType.Attributes.Add("onblur", "ShowValidationEffect('" + ddlEngineType.ClientID + "','" + rfvEngineType.ClientID + "')");
            //txtPurchasePrice.Attributes.Add("onblur", "ShowValidationEffect('" + txtPurchasePrice.ClientID + "','" + revPurchasePrice.ClientID + "')");
            txtEngineNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtEngineNo.ClientID + "','" + rfvEngineNo.ClientID + "')");
            txtChassisNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtChassisNo.ClientID + "','" + rfvChassisNo.ClientID + "')");
            txtVMReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtVMReason.ClientID + "','" + rfvVMReason.ClientID + "')");
            ddlHirePurchaseCompany.Attributes.Add("onblur", "ShowValidationEffect('" + ddlHirePurchaseCompany.ClientID + "','" + rfvHirePurchaseCompany.ClientID + "')");
            //txtOtherReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtOtherReason.ClientID + "','" + rfvOtherReason.ClientID + "')");
            //txtBank.Attributes.Add("onblur", "ShowValidationEffect('" + txtBank.ClientID + "','" + rfvBank.ClientID + "')");
            //txtChequeNo.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtChequeNo.ClientID + "','" + rfvChequeNo.ClientID + "','" + revChequeNo.ClientID + "')");
            txtNameoftheCard.Attributes.Add("onblur", "ShowValidationEffect('" + txtNameoftheCard.ClientID + "','" + rfvNameoftheCard.ClientID + "')");
            txtIssuingBank.Attributes.Add("onblur", "ShowValidationEffect('" + txtIssuingBank.ClientID + "','" + rfvIssuingBank.ClientID + "')");
            txtCardNo1.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo1.ClientID + "','" + rfvCardNo1.ClientID + "','" + revCardNo1.ClientID + "')");
            txtCardNo2.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo2.ClientID + "','" + rfvCardNo2.ClientID + "','" + revCardNo2.ClientID + "')");
            txtCardNo3.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo3.ClientID + "','" + rfvCardNo3.ClientID + "','" + revCardNo3.ClientID + "')");
            txtCardNo4.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo4.ClientID + "','" + rfvCardNo4.ClientID + "','" + revCardNo4.ClientID + "')");
            ddlCardExpiryMonth.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCardExpiryMonth.ClientID + "','" + rfvCardExpiryMonth.ClientID + "')");
            ddlCardExpiryYear.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCardExpiryYear.ClientID + "','" + rfvCardExpiryYear.ClientID + "')");
            ddlNCDReason.Attributes.Add("onblur", "ShowValidationEffect('" + ddlNCDReason.ClientID + "','" + rfvNCDReasonDdl.ClientID + "')");
            txtDriverSurName1.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName1.ClientID + "','" + rfvDriverSurName1.ClientID + "')");
            txtDriverSurName2.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName2.ClientID + "','" + rfvDriverSurName2.ClientID + "')");
            txtDriverSurName3.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName3.ClientID + "','" + rfvDriverSurName3.ClientID + "')");
            txtDriverSurName4.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName4.ClientID + "','" + rfvDriverSurName4.ClientID + "')");
            txtDriverSurName5.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName5.ClientID + "','" + rfvDriverSurName5.ClientID + "')");

            ddlYearofObtained.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofObtained.ClientID + "','" + rfvYearofObtained.ClientID + "')");
            txtNatureofAccident.Attributes.Add("onblur", "ShowValidationEffect('" + txtNatureofAccident.ClientID + "','" + rfvNatureofAccident.ClientID + "')");
            ddlTyeofClaim.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTyeofClaim.ClientID + "','" + rfvTyeofClaim.ClientID + "')");
            ddlYearofRevoked.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofRevoked.ClientID + "','" + rfvYearofRevoked.ClientID + "')");
            txtLicenceRevokedReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtLicenceRevokedReason.ClientID + "','" + rfvLicenceRevokedReason.ClientID + "')");

            ddlYearofObtainedDriver1.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofObtainedDriver1.ClientID + "','" + rfvYearofObtainedDriver1.ClientID + "')");
            txtNatureofAccidentDriver1.Attributes.Add("onblur", "ShowValidationEffect('" + txtNatureofAccidentDriver1.ClientID + "','" + rfvNatureofAccidentDriver1.ClientID + "')");
            txtClaimAmountDriver1.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimAmountDriver1.ClientID + "','" + rfvClaimAmountDriver1.ClientID + "','" + revClaimAmountDriver1.ClientID + "')");
            ddlTyeofClaimDriver1.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTyeofClaimDriver1.ClientID + "','" + rfvTyeofClaimDriver1.ClientID + "')");
            ddlYearofRevokedDriver1.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofRevokedDriver1.ClientID + "','" + rfvYearofRevokedDriver1.ClientID + "')");
            txtLicRevokReason1.Attributes.Add("onblur", "ShowValidationEffect('" + txtLicRevokReason1.ClientID + "','" + rfvLicRevokReason1.ClientID + "')");

            ddlYearofObtainedDriver2.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofObtainedDriver2.ClientID + "','" + rfvYearofObtainedDriver2.ClientID + "')");
            txtNatureofAccidentDriver2.Attributes.Add("onblur", "ShowValidationEffect('" + txtNatureofAccidentDriver2.ClientID + "','" + rfvNatureofAccidentDriver2.ClientID + "')");
            txtClaimAmountDriver2.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimAmountDriver2.ClientID + "','" + rfvClaimAmountDriver2.ClientID + "','" + revClaimAmountDriver2.ClientID + "')");
            ddlTyeofClaimDriver2.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTyeofClaimDriver2.ClientID + "','" + rfvTyeofClaimDriver2.ClientID + "')");
            ddlYearofRevokedDriver2.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofRevokedDriver2.ClientID + "','" + rfvYearofRevokedDriver2.ClientID + "')");
            txtLicRevokReason2.Attributes.Add("onblur", "ShowValidationEffect('" + txtLicRevokReason2.ClientID + "','" + rfvLicRevokReason2.ClientID + "')");

            ddlYearofObtainedDriver3.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofObtainedDriver3.ClientID + "','" + rfvYearofObtainedDriver3.ClientID + "')");
            txtNatureofAccidentDriver3.Attributes.Add("onblur", "ShowValidationEffect('" + txtNatureofAccidentDriver3.ClientID + "','" + rfvNatureofAccidentDriver3.ClientID + "')");
            txtClaimAmountDriver3.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimAmountDriver3.ClientID + "','" + rfvClaimAmountDriver3.ClientID + "','" + revClaimAmountDriver3.ClientID + "')");
            ddlTyeofClaimDriver3.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTyeofClaimDriver3.ClientID + "','" + rfvTyeofClaimDriver3.ClientID + "')");
            ddlYearofRevokedDriver3.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofRevokedDriver3.ClientID + "','" + rfvYearofRevokedDriver3.ClientID + "')");
            txtLicRevokReason3.Attributes.Add("onblur", "ShowValidationEffect('" + txtLicRevokReason3.ClientID + "','" + rfvLicRevokReason3.ClientID + "')");

            ddlYearofObtainedDriver4.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofObtainedDriver4.ClientID + "','" + rfvYearofObtainedDriver4.ClientID + "')");
            txtNatureofAccidentDriver4.Attributes.Add("onblur", "ShowValidationEffect('" + txtNatureofAccidentDriver4.ClientID + "','" + rfvNatureofAccidentDriver4.ClientID + "')");
            txtClaimAmountDriver4.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimAmountDriver4.ClientID + "','" + rfvClaimAmountDriver4.ClientID + "','" + revClaimAmountDriver4.ClientID + "')");
            ddlTyeofClaimDriver4.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTyeofClaimDriver4.ClientID + "','" + rfvTyeofClaimDriver4.ClientID + "')");
            ddlYearofRevokedDriver4.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofRevokedDriver4.ClientID + "','" + rfvYearofRevokedDriver4.ClientID + "')");
            txtLicRevokReason4.Attributes.Add("onblur", "ShowValidationEffect('" + txtLicRevokReason4.ClientID + "','" + rfvLicRevokReason4.ClientID + "')");

            ddlYearofObtainedDriver5.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofObtainedDriver5.ClientID + "','" + rfvYearofObtainedDriver5.ClientID + "')");
            txtNatureofAccidentDriver5.Attributes.Add("onblur", "ShowValidationEffect('" + txtNatureofAccidentDriver5.ClientID + "','" + rfvNatureofAccidentDriver5.ClientID + "')");
            txtClaimAmountDriver5.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimAmountDriver5.ClientID + "','" + rfvClaimAmountDriver5.ClientID + "','" + revClaimAmountDriver5.ClientID + "')");
            ddlTyeofClaimDriver5.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTyeofClaimDriver5.ClientID + "','" + rfvTyeofClaimDriver5.ClientID + "')");
            ddlYearofRevokedDriver5.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearofRevokedDriver5.ClientID + "','" + rfvYearofRevokedDriver5.ClientID + "')");
            txtLicRevokReason5.Attributes.Add("onblur", "ShowValidationEffect('" + txtLicRevokReason5.ClientID + "','" + rfvLicRevokReason5.ClientID + "')");
            //rdoYesInsuranceTransferred.Attributes.Add("onblur", "CheckInsuranceTransferredValidationCss();");
            //rdoNoInsuranceTransferred.Attributes.Add("onblur", "CheckInsuranceTransferredValidationCss();");
            rdoYesVechicleModification.Attributes.Add("onblur", "CheckVechicleModificationValidationCss();");
            rdoNoVechicleModification.Attributes.Add("onblur", "CheckVechicleModificationValidationCss();");
            rdoYesHirePurchase.Attributes.Add("onblur", "CheckHirePurchaseValidationCss();");
            rdoNoHirePurchase.Attributes.Add("onblur", "CheckHirePurchaseValidationCss();");
            //rdoSocial.Attributes.Add("onblur", "CheckPurposeofuseValidationCss();");
            //rdoOthers.Attributes.Add("onblur", "CheckPurposeofuseValidationCss();");
            //rdoCashorNets.Attributes.Add("onblur", "CheckPaymentModeValidationCss();");
            //rdoCheque.Attributes.Add("onblur", "CheckPaymentModeValidationCss();");
            //rdoCreditCard.Attributes.Add("onblur", "CheckPaymentModeValidationCss();");

            rdoYesLicenceRevoked.Attributes.Add("onblur", "CheckLicenceRevokedValidationCss();");
            rdoNoLicenceRevoked.Attributes.Add("onblur", "CheckLicenceRevokedValidationCss();");
            rdoYesRevoked1.Attributes.Add("onblur", "CheckRevoked1ValidationCss();");
            rdoNoRevoked1.Attributes.Add("onblur", "CheckRevoked1ValidationCss();");
            rdoYesRevoked2.Attributes.Add("onblur", "CheckRevoked2ValidationCss();");
            rdoNoRevoked2.Attributes.Add("onblur", "CheckRevoked2ValidationCss();");
            rdoYesRevoked3.Attributes.Add("onblur", "CheckRevoked3ValidationCss();");
            rdoNoRevoked3.Attributes.Add("onblur", "CheckRevoked3ValidationCss();");
            rdoYesRevoked4.Attributes.Add("onblur", "CheckRevoked4ValidationCss();");
            rdoNoRevoked4.Attributes.Add("onblur", "CheckRevoked4ValidationCss();");
            rdoYesRevoked5.Attributes.Add("onblur", "CheckRevoked5ValidationCss();");
            rdoNoRevoked5.Attributes.Add("onblur", "CheckRevoked5ValidationCss();");
            rdoYesDriverClaim1.Attributes.Add("onblur", "CheckDriverClaim1ValidationCss();");
            rdoNoDriverClaim1.Attributes.Add("onblur", "CheckDriverClaim1ValidationCss();");
            rdoYesDriverClaim2.Attributes.Add("onblur", "CheckDriverClaim2ValidationCss();");
            rdoNoDriverClaim2.Attributes.Add("onblur", "CheckDriverClaim2ValidationCss();");
            rdoYesDriverClaim3.Attributes.Add("onblur", "CheckDriverClaim3ValidationCss();");
            rdoNoDriverClaim3.Attributes.Add("onblur", "CheckDriverClaim3ValidationCss();");
            rdoYesDriverClaim4.Attributes.Add("onblur", "CheckDriverClaim4ValidationCss();");
            rdoNoDriverClaim4.Attributes.Add("onblur", "CheckDriverClaim4ValidationCss();");
            rdoYesDriverClaim5.Attributes.Add("onblur", "CheckDriverClaim5ValidationCss();");
            rdoNoDriverClaim5.Attributes.Add("onblur", "CheckDriverClaim5ValidationCss();");

            rdoVisa.Attributes.Add("onblur", "CheckCardTypeValidationCss();");
            rdoMasterCard.Attributes.Add("onblur", "CheckCardTypeValidationCss();");
            #endregion

            #region Set Property
            if (Session[CE.Global.General.UserPhoneNo] != null)
            {
                txtMobileNo.PhoneNo = Session[CE.Global.General.UserPhoneNo].ToString();
            }
            if (Session[CE.Global.General.UserName] != null)
            {
                txtGivenName.Text = Session[CE.Global.General.UserName].ToString();
            }
            LoadCarPolicyDetails();
            if (Session[General.CarMoreDetailId] != null && Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()) == 23)
            {
                _CarId = Convert.ToInt64(Session[General.CarId].ToString());
                _CarMoreId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
                _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                _CXCTypeId = Convert.ToInt64(Session[CE.Global.General.CarResultId].ToString());
                _ProviderId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            }

            #endregion

            Session[General.ViewedDetailsId] = LogUserViewedHistory().ToString();

            CheckSelectedNCD();

            GetNCDProtection();

            //lnkBackTop.HRef = Request.UrlReferrer.ToString();            
            //lnkBackBottom.HRef = Request.UrlReferrer.ToString();

        }
        //if (Page.ClientScript.IsStartupScriptRegistered("addScriptShowHideAll") == false)
        //{
        //    Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "addScriptShowHideDriver", "ShowHideAll()", true);
        //}
        //if (rdoYesInsuranceTransferred.Checked || rdoNoInsuranceTransferred.Checked) txtInsuranceTransferred.Text = "1";
        if (rdoYesLicenceRevoked.Checked || rdoNoLicenceRevoked.Checked) txtLicenceRevoked.Text = "1";
        if (rdoYesRevoked1.Checked || rdoNoRevoked1.Checked) txtRevoked1.Text = "1";
        if (rdoYesRevoked2.Checked || rdoNoRevoked2.Checked) txtRevoked2.Text = "1";
        if (rdoYesRevoked3.Checked || rdoNoRevoked3.Checked) txtRevoked3.Text = "1";
        if (rdoYesRevoked4.Checked || rdoNoRevoked4.Checked) txtRevoked4.Text = "1";
        if (rdoYesRevoked5.Checked || rdoNoRevoked5.Checked) txtRevoked5.Text = "1";
        if (rdoYesDriverClaim1.Checked || rdoNoDriverClaim1.Checked) txtDriverClaim1.Text = "1";
        if (rdoYesDriverClaim2.Checked || rdoNoDriverClaim2.Checked) txtDriverClaim2.Text = "1";
        if (rdoYesDriverClaim3.Checked || rdoNoDriverClaim3.Checked) txtDriverClaim3.Text = "1";
        if (rdoYesDriverClaim4.Checked || rdoNoDriverClaim4.Checked) txtDriverClaim4.Text = "1";
        if (rdoYesDriverClaim5.Checked || rdoNoDriverClaim5.Checked) txtDriverClaim5.Text = "1";
        if (rdoYesVechicleModification.Checked || rdoNoVechicleModification.Checked) txtVechicleModification.Text = "1";
        if (rdoYesHirePurchase.Checked || rdoNoHirePurchase.Checked) txtHirePurchase.Text = "1";
        //if (rdoSocial.Checked || rdoOthers.Checked) txtPurposeofuse.Text = "1";
        //if (rdoCashorNets.Checked || rdoCheque.Checked || rdoCreditCard.Checked) txtPaymentMode.Text = "1";
        if (rdoVisa.Checked || rdoMasterCard.Checked) txtCardType.Text = "1";

    }

    protected void CheckSelectedNCD()
    {
        //ddlNCDReason

        CarPolicy _carpolicy = new CarPolicy();
        CarPolicyDB _cardb = new CarPolicyDB();

        _carpolicy = _cardb.GetCarPolicy(Convert.ToInt64(Session[General.CarId].ToString()), Convert.ToInt64(Session[General.UserId].ToString()));

        if (_carpolicy != null)
        {
            if ((_carpolicy.NCDPercent.ToString() == "0" || _carpolicy.NCDPercent.ToString() == "10") && _carpolicy.IsClaimLastThreeYear == false)
            {
                ddlNCDReason.Items.Remove("Not Applicable");
            }
        }

    }

    protected void ibtSubmit_Click(object sender, ImageClickEventArgs e)
    {
        if (Session[CE.Global.General.CarResultId] != null)
        {
            if (Session[General.ProviderCompanyId].ToString() != "23")
            {
                Response.Redirect("~/user/viewresulthistory.aspx");
            }
        }
        else
        {
            Response.Redirect("~/user/viewresulthistory.aspx");
        }
        CheckValidation();
        ChangeValidationEffectServerSide("proposal");
        if (IsValid)
        {
            //if (!CheckCarQuoteUpdateStatus())
            //{
            //    Response.Redirect("profile.aspx");
            //}

            Int64 _carmoreresult = 0;
            Int64 driverresult = 0;
            Int64 _claimresult = 0;
            HsbcCarMoreDetail _hsbccarmoredetail = new HsbcCarMoreDetail();
            HsbcCarMoreDetailDB _hsbccarmoredetaildb = new HsbcCarMoreDetailDB();

            if (Session[General.CarMoreDetailId] != null)
            {
                _hsbccarmoredetail.CECarMoreDetailId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
            }
            else
            {
                _hsbccarmoredetail.CECarMoreDetailId = 0;
            }
            _hsbccarmoredetail.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
            _hsbccarmoredetail.ProviderCompanyId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
            _hsbccarmoredetail.Salutation = ddlSalutation.GetSalutation();
            _hsbccarmoredetail.FamilyName = txtFamilyName.Text.ToUpper();
            _hsbccarmoredetail.GivenName = txtGivenName.Text.ToUpper();
            _hsbccarmoredetail.Race = ddlRace.Text;
            _hsbccarmoredetail.PostalCode = txtPostCode.Text.Trim();
            _hsbccarmoredetail.UnitNo = txtUnit1.Text.Trim();
            _hsbccarmoredetail.HomeNo = txtUnit2.Text.Trim();
            _hsbccarmoredetail.Address = txtAddress.Text.Trim();
            _hsbccarmoredetail.NRICNo = ddlIdNumber.GetIdNumber();
            _hsbccarmoredetail.Nationality = ddlNationality.GetNationality();
            _hsbccarmoredetail.MobileNo = txtMobileNo.GetPhoneNo();
            _hsbccarmoredetail.HomePhoneNo = txtResidentialPhoneNo.GetPhoneNo();
            _hsbccarmoredetail.OfficePhoneNo = txtOfficePhoneNo.GetPhoneNo();
            _hsbccarmoredetail.FaxNo = txtFaxNo.GetPhoneNo();
            _hsbccarmoredetail.EmpName = txtEmpName.Text.Trim();
            //_hsbccarmoredetail.HasInsuranceTransferred = rdoYesInsuranceTransferred.Checked;
            //if (rdoYesInsuranceTransferred.Checked == true)
            //{
            _hsbccarmoredetail.InsCompanyName = ddlTransInsuranceCompany.Text;
            // _hsbccarmoredetail.InsVechicleNo = txtTransInsVehicleNo.Text;
            //}
            //else
            //{
            // _hsbccarmoredetail.InsCompanyName = "";
            //_hsbccarmoredetail.InsVechicleNo = "";
            //}

            _hsbccarmoredetail.NCDReason = ddlNCDReason.SelectedValue;
            if (ddlNCDReason.SelectedValue == "Others")
            {
                _hsbccarmoredetail.NCDOtherReason = txtNCDReason.Text.Trim();
            }
            else
            {
                _hsbccarmoredetail.NCDOtherReason = "";
            }
            _hsbccarmoredetail.VechicleNo = txtVehicleNo.Text.Trim();
            _hsbccarmoredetail.EngineType = ddlEngineType.Text;
            if (txtPurchasePrice.Text.Trim() != "")
            {
                _hsbccarmoredetail.PurchasePrice = Convert.ToSingle(txtPurchasePrice.Text.Trim());
            }
            else
            {
                _hsbccarmoredetail.PurchasePrice = 0;
            }
            _hsbccarmoredetail.EngineNo = txtEngineNo.Text.Trim();
            _hsbccarmoredetail.ChassisNo = txtChassisNo.Text.Trim();
            _hsbccarmoredetail.HasVechicleModified = rdoYesVechicleModification.Checked;
            if (rdoYesVechicleModification.Checked == true)
            {
                _hsbccarmoredetail.VechicleModifyReason = txtVMReason.Text.Trim();
            }
            else
            {
                _hsbccarmoredetail.VechicleModifyReason = "";
            }
            _hsbccarmoredetail.HasHirePurchase = rdoYesHirePurchase.Checked;
            if (rdoYesHirePurchase.Checked == true)
            {
                _hsbccarmoredetail.HPCompanyName = ddlHirePurchaseCompany.Text.Trim();
            }
            else
            {
                _hsbccarmoredetail.HPCompanyName = "";
            }
           
            _hsbccarmoredetail.PamentType = "CreditCard";
            _hsbccarmoredetail.QuoteRefNo = lblQRefNo.Text.Trim();

            _hsbccarmoredetail.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _hsbccarmoredetail.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _hsbccarmoredetail.Status = true;
            _hsbccarmoredetail.CarResultId = Convert.ToInt64(Session[General.CarResultId].ToString());

            _hsbccarmoredetail.Info1 = rdoYesYoungDriver.Checked.ToString();
            _hsbccarmoredetail.Info2 = rdoYesCompanyCar.Checked.ToString();
            _hsbccarmoredetail.Info3 = rdoYesDeclinedCar.Checked.ToString();
            //_hsbccarmoredetail.Info4 = rdoYesNONCDProtect.Checked.ToString();
            //_hsbccarmoredetail.Info5 = rdoYesCOE.Checked.ToString();

            if (rdoYes.Checked == true)
            {
                _hsbccarmoredetail.Info4 = rdoYes.Checked.ToString();
                _hsbccarmoredetail.Info7 = "1";
            }
            else
            {
                _hsbccarmoredetail.Info4 = "False";
                _hsbccarmoredetail.Info7 = "0";
            }
            

            if (inputCovertype.Value.Trim() == "5" || inputCovertype.Value.Trim() == "6")  //WITHOUT COE covertype ids
                _hsbccarmoredetail.Info5 = "True";
            else
                _hsbccarmoredetail.Info5 = "False";

            _hsbccarmoredetail.Info6 = "False"; //rdoYesSocialPurpose.Checked.ToString();

            _hsbccarmoredetail.OtherReason = ddlPurpose.Text;

            _hsbccarmoredetail.YearofObtained = Convert.ToInt32(ddlYearofObtained.Text);
            _hsbccarmoredetail.HasLicenceRevoked = rdoYesLicenceRevoked.Checked;
            _hsbccarmoredetail.YearofRevoked = Convert.ToInt32(ddlYearofRevoked.Text);
            _hsbccarmoredetail.RevokedReason = txtLicenceRevokedReason.Text;
            

            _carmoreresult = _hsbccarmoredetaildb.Insert(_hsbccarmoredetail);

            if (_carmoreresult > 0)
            {
                Int64 _paymentresult = 0;
                Payment _payment = new Payment();
                PaymentDB _paymentdb = new PaymentDB();

                _payment.CXPaymentId = 0;
                _payment.RefId = Convert.ToInt64(Session[General.CarId].ToString());
                _payment.ProviderCompanyId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
                _payment.InsuranceType = "CI";
                _payment.NameoftheCard = txtNameoftheCard.Text.ToUpper();
                _payment.IssuingBankName = txtIssuingBank.Text.Trim();
                _payment.CreditCardNo = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
                _payment.CardExpiryMonth = ddlCardExpiryMonth.Text;
                _payment.CardExpiryYear = ddlCardExpiryYear.Text;
                if (rdoAnnualPayment.Checked)
                {
                    _payment.InstallmentType = 1;
                }
                else if (rdoMonthlyPayment.Checked)
                {
                    _payment.InstallmentType = 2;
                }

                if (rdoVisa.Checked == true)
                {
                    _payment.CardType = "Visa";
                }
                else
                {
                    _payment.CardType = "MasterCard";
                }
                _payment.Status = true;
                if (Session[CE.Global.General.UserId] != null)
                {
                    _payment.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                }
                else
                {
                    _payment.RefCEUserId = 0;
                }
                _paymentresult = _paymentdb.Insert(_payment);

                if (_paymentresult > 0)
                {
                    if (txtAnyClaim.Text.Trim() == "Yes")
                    {
                        if (!SaveDriverClaimHistory())
                        {
                            lblMessage.Text = "Driver Claim History Saved Faild.";
                        }
                        else
                        {
                            _claimresult = 1;
                        }
                    }
                    else
                    {
                        _claimresult = 1;
                    }
                    if (_claimresult > 0)
                    {
                        if (txtDriverCount.Text.Trim() != "0")
                        {
                            if (!UpdateDriverDetails())
                            {
                                lblMessage.Text = "Car Drivers failed to save!";
                            }
                            else
                            {
                                driverresult = 1;
                            }
                        }
                        else
                        {
                            driverresult = 1;
                        }
                        if (driverresult > 0)
                        {

                            string _filePath = GetFilePathHsbc();
                            string _fileName = lblQRefNo.Text.Trim() + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                            _filePath += _fileName + ".pdf";

                            Int64 _statusresult = 0;
                            _hsbccarmoredetail.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
                            _hsbccarmoredetail.CarResultId = Convert.ToInt64(Session[General.CarResultId].ToString());
                            _hsbccarmoredetail.Info10 = _filePath;

                            _statusresult = _hsbccarmoredetaildb.UpdateStatus(_hsbccarmoredetail);

                            Session[CE.Global.General.CarMoreDetailId] = _carmoreresult.ToString();
                            UserConfirmation _userconfirm = new UserConfirmation();
                            UserConfirmationDB _userconfirmdb = new UserConfirmationDB();
                            _userconfirm.ConfirmationType = "CI";
                            _userconfirm.CurrentStep = 4;
                            //_userconfirm.UserResultId = Convert.ToInt64(Session[General.CarResultId].ToString());
                            _userconfirm.UserSelectedId = Convert.ToInt64(Session[General.CarResultId].ToString());
                            _userconfirm.FirstStepId = Convert.ToInt64(Session[General.CarId].ToString());
                            _userconfirm.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
                            _userconfirm.IsConfirm = true;
                            _userconfirm.ResultStatus = "Complete";
                            _userconfirm.IsComplete = true;
                            Int64 _result = _userconfirmdb.Insert(_userconfirm);
                            if ((_result > 0) && (_statusresult > 0))
                            {
                                ProposalNotification();
                                string _provideid = Encode(Session[General.ProviderCompanyId].ToString());
                                //GenerateProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId]));
                                string _refid = "";
                                string convertno = General.GetRefNumber(Convert.ToInt64(Session[CE.Global.General.CarId]));
                                _refid = "H" + convertno;
                                GeneratePDFProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId]));
                                General.ClearAllSession(this.Page, "ALL");
                                Response.Redirect("~/car-insurance/usermessage.aspx?pcid=" + _provideid + "&ref=" + _refid);
                            }
                            else
                            {
                                lblMessage.Text = "Can't update confirmation status.";
                            }
                        }
                    }
                }
                else
                {
                    lblMessage.Text = "Payment Details Saved Faild.";
                }
            }
        }
    }
    
    protected void ibtnBack_Click(object sender, ImageClickEventArgs e)
    {
        //Response.Redirect("~/car-insurance/results.aspx?sortby=0");
        Response.Redirect("~/car-insurance/your-request.aspx");
    }

    protected void imgbtnBackTop_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["FromSummary"] != null)
        {
            if (Session["FromSummary"].ToString().Trim() == "1")
            {
                Response.Redirect("~/car-insurance/results-new.aspx");
            }
            else
            {
                Response.Redirect("~/car-insurance/results-details.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/results-new.aspx");
        }
    }

    protected void txtPostCode_TextChanged(object sender, EventArgs e)
    {
        GetPostCode();
    }

    protected void ddlAddressList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlAddressList.Items.Count > 0 && ddlAddressList.SelectedIndex >= 0)
        {
            txtAddress.Text = ddlAddressList.Text;
        }
    }

    protected void btnPostCode_Click(object sender, EventArgs e)
    {
        txtAddress.Text = "";
        //ChangeValidationEffectServerSide("maincardholder");
        PostCode _postcode = new PostCode();
        _postcode = GetPostCode(txtPostCode.Text);
        if (_postcode != null)
        {
            if (_postcode.BuildingName.Trim() != string.Empty)
            {
                txtAddress.Text += _postcode.BuildingName + ", ";
            }

            if (_postcode.StreetName.Trim() != string.Empty)
            {
                txtAddress.Text += _postcode.StreetName;
            }
        }
        else
        {
            txtAddress.Text = "No Address Found.";
        }
        _postcode = null;
    }

    private bool UpdateDriverDetails()
    {
        bool _result = false;
        //Int64 _demeritresult = 0;
        CarDriver _cardriver = new CarDriver();
        CarDriverDB _cardriverdb = new CarDriverDB();

        if (txtDriverCount.Text.Trim() != "0")
        {
            int _drivercount = Convert.ToInt32(txtDriverCount.Text.Trim());
            int _insertcount = 0;

            for (int i = 1; i <= _drivercount; i++)
            {
                _cardriver.StepId = 2;
                _cardriver.RerCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                _cardriver.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
                if (i == 1)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId1.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation1.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName1.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName1.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType1.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber1.GetIdNumber();
                    _cardriver.DOB = CE.Global.General.GetUTCDateTime();

                    _cardriver.Info11 = ddlYearofObtainedDriver1.Text;
                    _cardriver.Info12 = ddlDriverRelationship1.GetRelationship();
                    _cardriver.Info13 = rdoYesRevoked1.Checked.ToString();
                    _cardriver.Info14 = ddlYearofRevokedDriver1.Text;
                    _cardriver.Info15 = txtLicRevokReason1.Text;
                    _cardriver.Info16 = rdoYesDriverClaim1.Checked.ToString();
                    //New Start
                    DateTime _AcciDate1 = ddlDateofAccidentDriver1.GetDate();
                    string _accdate1 = _AcciDate1.Day.ToString("00") + "/" + _AcciDate1.Month.ToString("00") + "/" + _AcciDate1.Year.ToString("0000");
                    _cardriver.Info17 = _accdate1.ToString();
                    //_cardriver.Info17 = ddlDateofAccidentDriver1.GetDate().ToString();
                    //New End
                    _cardriver.Info18 = txtNatureofAccidentDriver1.Text;
                    _cardriver.Info19 = txtClaimAmountDriver1.Text;
                    _cardriver.Info20 = ddlTyeofClaimDriver1.Text;

                    _cardriver.Status = "Active";
                }
                else if (i == 2)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId2.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation2.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName2.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName2.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType2.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber2.GetIdNumber();
                    _cardriver.DOB = CE.Global.General.GetUTCDateTime();

                    _cardriver.Info11 = ddlYearofObtainedDriver2.Text;
                    _cardriver.Info12 = ddlDriverRelationship2.GetRelationship();
                    _cardriver.Info13 = rdoYesRevoked2.Checked.ToString();
                    _cardriver.Info14 = ddlYearofRevokedDriver2.Text;
                    _cardriver.Info15 = txtLicRevokReason2.Text;
                    _cardriver.Info16 = rdoYesDriverClaim2.Checked.ToString();
                    //New Start
                    DateTime _AcciDate2 = ddlDateofAccidentDriver2.GetDate();
                    string _accdate2 = _AcciDate2.Day.ToString("00") + "/" + _AcciDate2.Month.ToString("00") + "/" + _AcciDate2.Year.ToString("0000");
                    _cardriver.Info17 = _accdate2.ToString();
                    //_cardriver.Info17 = ddlDateofAccidentDriver2.GetDate().ToString();
                    //New End
                    _cardriver.Info18 = txtNatureofAccidentDriver2.Text;
                    _cardriver.Info19 = txtClaimAmountDriver2.Text;
                    _cardriver.Info20 = ddlTyeofClaimDriver2.Text;

                    _cardriver.Status = "Active";
                }
                else if (i == 3)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId3.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation3.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName3.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName3.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType3.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber3.GetIdNumber();
                    _cardriver.DOB = CE.Global.General.GetUTCDateTime();

                    _cardriver.Info11 = ddlYearofObtainedDriver3.Text;
                    _cardriver.Info12 = ddlDriverRelationship3.GetRelationship();
                    _cardriver.Info13 = rdoYesRevoked3.Checked.ToString();
                    _cardriver.Info14 = ddlYearofRevokedDriver3.Text;
                    _cardriver.Info15 = txtLicRevokReason3.Text;
                    _cardriver.Info16 = rdoYesDriverClaim3.Checked.ToString();
                    //New Start
                    DateTime _AcciDate3 = ddlDateofAccidentDriver3.GetDate();
                    string _accdate3 = _AcciDate3.Day.ToString("00") + "/" + _AcciDate3.Month.ToString("00") + "/" + _AcciDate3.Year.ToString("0000");
                    _cardriver.Info17 = _accdate3.ToString();
                    //_cardriver.Info17 = ddlDateofAccidentDriver3.GetDate().ToString();
                    //New End
                    _cardriver.Info18 = txtNatureofAccidentDriver3.Text;
                    _cardriver.Info19 = txtClaimAmountDriver3.Text;
                    _cardriver.Info20 = ddlTyeofClaimDriver3.Text;

                    _cardriver.Status = "Active";
                }
                else if (i == 4)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId4.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation4.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName4.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName4.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType4.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber4.GetIdNumber();
                    _cardriver.DOB = CE.Global.General.GetUTCDateTime();

                    _cardriver.Info11 = ddlYearofObtainedDriver4.Text;
                    _cardriver.Info12 = ddlDriverRelationship4.GetRelationship();
                    _cardriver.Info13 = rdoYesRevoked4.Checked.ToString();
                    _cardriver.Info14 = ddlYearofRevokedDriver4.Text;
                    _cardriver.Info15 = txtLicRevokReason4.Text;
                    _cardriver.Info16 = rdoYesDriverClaim4.Checked.ToString();
                    //New Start
                    DateTime _AcciDate4 = ddlDateofAccidentDriver4.GetDate();
                    string _accdate4 = _AcciDate4.Day.ToString("00") + "/" + _AcciDate4.Month.ToString("00") + "/" + _AcciDate4.Year.ToString("0000");
                    _cardriver.Info17 = _accdate4.ToString();
                    //_cardriver.Info17 = ddlDateofAccidentDriver4.GetDate().ToString();
                    //New End
                    _cardriver.Info18 = txtNatureofAccidentDriver4.Text;
                    _cardriver.Info19 = txtClaimAmountDriver4.Text;
                    _cardriver.Info20 = ddlTyeofClaimDriver4.Text;

                    _cardriver.Status = "Active";
                }
                else if (i == 5)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId5.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation5.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName5.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName5.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType5.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber5.GetIdNumber();
                    _cardriver.DOB = CE.Global.General.GetUTCDateTime();

                    _cardriver.Info11 = ddlYearofObtainedDriver5.Text;
                    _cardriver.Info12 = ddlDriverRelationship5.GetRelationship();
                    _cardriver.Info13 = rdoYesRevoked5.Checked.ToString();
                    _cardriver.Info14 = ddlYearofRevokedDriver5.Text;
                    _cardriver.Info15 = txtLicRevokReason5.Text;
                    _cardriver.Info16 = rdoYesDriverClaim5.Checked.ToString();
                    //New Start
                    DateTime _AcciDate5 = ddlDateofAccidentDriver5.GetDate();
                    string _accdate5 = _AcciDate5.Day.ToString("00") + "/" + _AcciDate5.Month.ToString("00") + "/" + _AcciDate5.Year.ToString("0000");
                    _cardriver.Info17 = _accdate5.ToString();
                    //_cardriver.Info17 = ddlDateofAccidentDriver5.GetDate().ToString();
                    //New End
                    _cardriver.Info18 = txtNatureofAccidentDriver5.Text;
                    _cardriver.Info19 = txtClaimAmountDriver5.Text;
                    _cardriver.Info20 = ddlTyeofClaimDriver5.Text;

                    _cardriver.Status = "Active";
                }
                _cardriver.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
                if (_cardriverdb.Insert(_cardriver) > 0)
                {
                    _insertcount++;
                    _result = true;
                }
            }
            _cardriverdb = null;
            _cardriver = null;
        }
        return _result;
    }

    private bool SaveDriverClaimHistory()
    {
        Int64 _claimresult = 0;
        DriverClaimHistory _driverclaimhistory = new DriverClaimHistory();
        DriverClaimHistoryDB _driverclaimhistorydb = new DriverClaimHistoryDB();
        _driverclaimhistory.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
        _driverclaimhistory.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
        _driverclaimhistory.AccidentDate = ddlDateofAccident.GetDate();
        _driverclaimhistory.NatureofAccident = txtNatureofAccident.Text;
        _driverclaimhistory.ClaimAmount = Convert.ToSingle(txtClaimAmount.Text);
        _driverclaimhistory.TypeofClaim = ddlTyeofClaim.Text;
        _driverclaimhistory.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
        _driverclaimhistory.Status = true;
        _claimresult = _driverclaimhistorydb.Insert(_driverclaimhistory);
        
        return _claimresult > 0;
    }

    public string Encode(string sData)
    {
        byte[] encData_byte = new byte[sData.Length];
        encData_byte = System.Text.Encoding.UTF8.GetBytes(sData);
        string encodedData = Convert.ToBase64String(encData_byte);
        return encodedData;
    }

    public void LoadCarPolicyDetails()
    {
        _CarId = Convert.ToInt64(Session[General.CarId].ToString());
        _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
        _CXCTypeId = Convert.ToInt64(Session[CE.Global.General.CarResultId].ToString());
        _ProviderId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
        //DataTable _dtProvider = new DataTable();
        DataSet _dtProvider = new DataSet();
        EtiqaCarMoreDetail _etiqacarmoredetail = new EtiqaCarMoreDetail();
        EtiqaCarMoreDetailDB _etiqacarmoredetaildb = new EtiqaCarMoreDetailDB();
        _dtProvider = _etiqacarmoredetaildb.GetCarPolicyDetails(_CarId, _UserId, _CXCTypeId, _ProviderId);
        if (_dtProvider != null)
        {
            if (_dtProvider.Tables[0].Rows.Count > 0 && _dtProvider.Tables[1].Rows.Count > 0 && _dtProvider.Tables[2].Rows.Count > 0)
            {
                //lblProvider.Text = _dtProvider.Rows[0]["CompanyName"].ToString();
                //lblPremium.Text = "$ " + _dtProvider.Rows[0]["AnnualPremium"].ToString();
                //lblPackage.Text = _dtProvider.Rows[0]["PlanName"].ToString();
                //lblPackageHead.Visible = true;
                //lblPremiumHead.Visible = true;
                lblYrofManufacture.Text = _dtProvider.Tables[0].Rows[0]["ManufactYear"].ToString();
                lblYrofRegister.Text = _dtProvider.Tables[0].Rows[0]["RegYear"].ToString();
                lblCarMakemodel.Text = _dtProvider.Tables[0].Rows[0]["MakeModelDesc"].ToString();
                lblOffpeakvehile.Text = _dtProvider.Tables[0].Rows[0]["Offbeak"].ToString();
                if (_dtProvider.Tables[0].Rows[0]["NCDPercent"].ToString() == "-1")
                {
                    lblNCDvalue.Text = "No NCD (First Policy)";
                }
                else
                {
                    lblNCDvalue.Text = _dtProvider.Tables[0].Rows[0]["NCDPercent"].ToString() + "%";
                }

                inputCurrentNCD.Value = _dtProvider.Tables[0].Rows[0]["NCDPercent"].ToString();
                inputNCD.Value = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString(); //ncd protect now based on 50% renewal ncd

                lblNCDRenewal.Text = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString() + "%";

                lblAnyclaim.Text = _dtProvider.Tables[0].Rows[0]["Claim"].ToString();
                txtAnyClaim.Text = _dtProvider.Tables[0].Rows[0]["Claim"].ToString();
                EnableClaim();
                if(txtAnyClaim.Text.Trim() == "Yes" && _dtProvider.Tables.Count > 3)
                {
                    string _claim3 = _dtProvider.Tables[3].Rows[0]["NOCLast3Value"].ToString();
                    string _claim2 = _dtProvider.Tables[3].Rows[0]["NOCLast2Value"].ToString();
                    string _claim1 = _dtProvider.Tables[3].Rows[0]["NOCLast1Value"].ToString();
                    if(Convert.ToInt32(_claim3) > 0)
                    {
                        txtClaimAmount.Text = _claim3;
                    }
                    else if (Convert.ToInt32(_claim2) > 0)
                    {
                        txtClaimAmount.Text = _claim2;
                    }
                    else if (Convert.ToInt32(_claim1) > 0)
                    {
                        txtClaimAmount.Text = _claim1;
                    }
                    else
                    {
                        txtClaimAmount.Text = "0";
                    }
                }
                else
                {
                    txtClaimAmount.Text = "0";
                }
                lblOffenceDriving.Text = _dtProvider.Tables[0].Rows[0]["OffDriveCom"].ToString();
                if (_dtProvider.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
                {
                    lblAddDriver.Text = _dtProvider.Tables[0].Rows[0]["NoOfDriver"].ToString();
                    txtDriverCount.Text = _dtProvider.Tables[0].Rows[0]["NoOfDriver"].ToString();
                }
                else
                {
                    lblAddDriver.Text = _dtProvider.Tables[0].Rows[0]["AddDriver"].ToString();
                    txtDriverCount.Text = "0";
                }
                EnableDriverPanels();
                lblCommencementdate.Text = _dtProvider.Tables[0].Rows[0]["CommenceDate"].ToString();
                lblSelectInsurer.Text = _dtProvider.Tables[1].Rows[0]["CompanyName"].ToString();

                //Sakthi on 30 Nov 2011 -- Start
                Int32 _PromoValue = Convert.ToInt32(_dtProvider.Tables[1].Rows[0]["PetrolVoucher"].ToString());
                if (_PromoValue == 100)
                {
                    divPromoVoucher.Visible = true;
                    imgPromoAdd1.Visible = true;
                    imgPromoAdd2.Visible = false;
                }
                else if (_PromoValue == 50)
                {
                    divPromoVoucher.Visible = true;
                    imgPromoAdd1.Visible = false;
                    imgPromoAdd2.Visible = true;
                }
                else
                {
                    divPromoVoucher.Visible = false;
                    imgPromoAdd1.Visible = false;
                    imgPromoAdd2.Visible = false;
                }
                //Sakthi on 30 Nov 2011 -- Else

                double _annualPremium = Convert.ToDouble(_dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString());
                double _monthlyPremium = _annualPremium / 12;
                lblPremiums.Text = "$" + _dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString(); //Sakthi on 08 Dec 2010 +" (" + String.Format("${0:0,0.00}", _monthlyPremium) + " per month)"; ; ;
                lblPremiumBeforeNCDProNoFormat.Text = _dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString();

                lblWorkshopPlan.Text = _dtProvider.Tables[1].Rows[0]["PlanName"].ToString() ;
                string convertno = General.GetRefNumber(_CarId);
                if (_ProviderId == 23)
                {
                    lblQRefNo.Text = "H" + convertno.ToString(); // +"_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                }
                else if (_ProviderId == 29)
                {
                    lblQRefNo.Text = "L" + convertno.ToString();
                }
                else if (_ProviderId == 30)
                {
                    lblQRefNo.Text = "E" + convertno.ToString();
                }

                inputCovertype.Value = _dtProvider.Tables[1].Rows[0]["CXCoverTypeId"].ToString();
            }
            else
            {
                //Response.Redirect("~/user/usermessage.aspx?errorcode=CI502");
                Response.Redirect("~/user/usermessage.aspx?mt=CI&ec=502");
            }
        }
        else
        {
            //Response.Redirect("~/user/usermessage.aspx?errorcode=CI502");
            Response.Redirect("~/user/usermessage.aspx?mt=CI&ec=502");
        }
        //else
        //{
        //    lblProvider.Text = "";
        //    lblPremium.Text = "";
        //    lblPackage.Text = "";
        //    lblPackageHead.Visible = false;
        //    lblPremiumHead.Visible = false;
        //}
        ddlTransInsuranceCompany.Text = _dtProvider.Tables[0].Rows[0]["Info1"].ToString();
        LoadCarDrivers();
    }

    private void LoadCarDrivers()
    {
        CarDriverDB _cardriverdb = new CarDriverDB();
        _CarId = Convert.ToInt64(Session[General.CarId].ToString());
        _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
        DataTable _driverList = _cardriverdb.GetDriverList(_CarId, _UserId);
        if (_driverList.Rows.Count > 0)
        {
            lblDriverId1.Text = _driverList.Rows[0]["CarDriverId"].ToString();

            DateTime _dtDOB1 = Convert.ToDateTime(_driverList.Rows[0]["DOB"].ToString());
            lblDriverDOB1.Text = _dtDOB1.Day.ToString("00") + "/" + _dtDOB1.Month.ToString("00") + "/" + _dtDOB1.Year.ToString("0000");
            ddlDriverGender1.Gender = _driverList.Rows[0]["Gender"].ToString();
            if (_driverList.Rows[0]["Gender"].ToString() == "M")
            {
                lblDriverGender1.Text = "Male";
            }
            else if (_driverList.Rows[0]["Gender"].ToString() == "F")
            {
                lblDriverGender1.Text = "Female";
            }
            if (_driverList.Rows[0]["Salutation"].ToString() != null && _driverList.Rows[0]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation1.Saluation = _driverList.Rows[0]["Salutation"].ToString();
            }
            if (_driverList.Rows[0]["Surname"].ToString() != null && _driverList.Rows[0]["Surname"].ToString() != "")
            {
                txtDriverSurName1.Text = _driverList.Rows[0]["Surname"].ToString();
            }
            if (_driverList.Rows[0]["GivenName"].ToString() != null && _driverList.Rows[0]["GivenName"].ToString() != "")
            {
                txtDriverGivenName1.Text = _driverList.Rows[0]["GivenName"].ToString();
            }
            if (_driverList.Rows[0]["IDType"].ToString() != null && _driverList.Rows[0]["IDType"].ToString() != "")
            {
                ddlDriverIdType1.IdType = _driverList.Rows[0]["IDType"].ToString();
            }
            if (_driverList.Rows[0]["IDNo"].ToString() != null && _driverList.Rows[0]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber1.Prefix = _driverList.Rows[0]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber1.Postfix = _driverList.Rows[0]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber1.IDNumber = _driverList.Rows[0]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 1)
        {
            lblDriverId2.Text = _driverList.Rows[1]["CarDriverId"].ToString();

            DateTime _dtDOB2 = Convert.ToDateTime(_driverList.Rows[1]["DOB"].ToString());
            lblDriverDOB2.Text = _dtDOB2.Day.ToString("00") + "/" + _dtDOB2.Month.ToString("00") + "/" + _dtDOB2.Year.ToString("0000");
            ddlDriverGender2.Gender = _driverList.Rows[1]["Gender"].ToString();
            if (_driverList.Rows[1]["Gender"].ToString() == "M")
            {
                lblDriverGender2.Text = "Male";
            }
            else if (_driverList.Rows[1]["Gender"].ToString() == "F")
            {
                lblDriverGender2.Text = "Female";
            }
            if (_driverList.Rows[1]["Salutation"].ToString() != null && _driverList.Rows[1]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation2.Saluation = _driverList.Rows[1]["Salutation"].ToString();
            }
            if (_driverList.Rows[1]["Surname"].ToString() != null && _driverList.Rows[1]["Surname"].ToString() != "")
            {
                txtDriverSurName2.Text = _driverList.Rows[1]["Surname"].ToString();
            }
            if (_driverList.Rows[1]["GivenName"].ToString() != null && _driverList.Rows[1]["GivenName"].ToString() != "")
            {
                txtDriverGivenName2.Text = _driverList.Rows[1]["GivenName"].ToString();
            }
            if (_driverList.Rows[1]["IDType"].ToString() != null && _driverList.Rows[1]["IDType"].ToString() != "")
            {
                ddlDriverIdType2.IdType = _driverList.Rows[1]["IDType"].ToString();
            }
            if (_driverList.Rows[1]["IDNo"].ToString() != null && _driverList.Rows[1]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber2.Prefix = _driverList.Rows[1]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber2.Postfix = _driverList.Rows[1]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber2.IDNumber = _driverList.Rows[1]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 2)
        {
            lblDriverId3.Text = _driverList.Rows[2]["CarDriverId"].ToString();

            DateTime _dtDOB3 = Convert.ToDateTime(_driverList.Rows[2]["DOB"].ToString());
            lblDriverDOB3.Text = _dtDOB3.Day.ToString("00") + "/" + _dtDOB3.Month.ToString("00") + "/" + _dtDOB3.Year.ToString("0000");
            ddlDriverGender3.Gender = _driverList.Rows[2]["Gender"].ToString();
            if (_driverList.Rows[2]["Gender"].ToString() == "M")
            {
                lblDriverGender3.Text = "Male";
            }
            else if (_driverList.Rows[2]["Gender"].ToString() == "F")
            {
                lblDriverGender3.Text = "Female";
            }
            if (_driverList.Rows[2]["Salutation"].ToString() != null && _driverList.Rows[2]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation3.Saluation = _driverList.Rows[2]["Salutation"].ToString();
            }
            if (_driverList.Rows[2]["Surname"].ToString() != null && _driverList.Rows[2]["Surname"].ToString() != "")
            {
                txtDriverSurName3.Text = _driverList.Rows[2]["Surname"].ToString();
            }
            if (_driverList.Rows[2]["GivenName"].ToString() != null && _driverList.Rows[2]["GivenName"].ToString() != "")
            {
                txtDriverGivenName3.Text = _driverList.Rows[2]["GivenName"].ToString();
            }
            if (_driverList.Rows[2]["IDType"].ToString() != null && _driverList.Rows[2]["IDType"].ToString() != "")
            {
                ddlDriverIdType3.IdType = _driverList.Rows[2]["IDType"].ToString();
            }
            if (_driverList.Rows[2]["IDNo"].ToString() != null && _driverList.Rows[2]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber3.Prefix = _driverList.Rows[2]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber3.Postfix = _driverList.Rows[2]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber3.IDNumber = _driverList.Rows[2]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 3)
        {
            lblDriverId4.Text = _driverList.Rows[3]["CarDriverId"].ToString();

            DateTime _dtDOB4 = Convert.ToDateTime(_driverList.Rows[3]["DOB"].ToString());
            lblDriverDOB4.Text = _dtDOB4.Day.ToString("00") + "/" + _dtDOB4.Month.ToString("00") + "/" + _dtDOB4.Year.ToString("0000");
            ddlDriverGender4.Gender = _driverList.Rows[3]["Gender"].ToString();
            if (_driverList.Rows[3]["Gender"].ToString() == "M")
            {
                lblDriverGender4.Text = "Male";
            }
            else if (_driverList.Rows[3]["Gender"].ToString() == "F")
            {
                lblDriverGender4.Text = "Female";
            }
            if (_driverList.Rows[3]["Salutation"].ToString() != null && _driverList.Rows[3]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation4.Saluation = _driverList.Rows[3]["Salutation"].ToString();
            }
            if (_driverList.Rows[3]["Surname"].ToString() != null && _driverList.Rows[3]["Surname"].ToString() != "")
            {
                txtDriverSurName4.Text = _driverList.Rows[3]["Surname"].ToString();
            }
            if (_driverList.Rows[3]["GivenName"].ToString() != null && _driverList.Rows[3]["GivenName"].ToString() != "")
            {
                txtDriverGivenName4.Text = _driverList.Rows[3]["GivenName"].ToString();
            }
            if (_driverList.Rows[3]["IDType"].ToString() != null && _driverList.Rows[3]["IDType"].ToString() != "")
            {
                ddlDriverIdType4.IdType = _driverList.Rows[3]["IDType"].ToString();
            }
            if (_driverList.Rows[3]["IDNo"].ToString() != null && _driverList.Rows[3]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber4.Prefix = _driverList.Rows[3]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber4.Postfix = _driverList.Rows[3]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber4.IDNumber = _driverList.Rows[3]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 4)
        {
            lblDriverId5.Text = _driverList.Rows[4]["CarDriverId"].ToString();

            DateTime _dtDOB5 = Convert.ToDateTime(_driverList.Rows[4]["DOB"].ToString());
            lblDriverDOB5.Text = _dtDOB5.Day.ToString("00") + "/" + _dtDOB5.Month.ToString("00") + "/" + _dtDOB5.Year.ToString("0000");
            ddlDriverGender5.Gender = _driverList.Rows[4]["Gender"].ToString();
            if (_driverList.Rows[4]["Gender"].ToString() == "M")
            {
                lblDriverGender5.Text = "Male";
            }
            else if (_driverList.Rows[4]["Gender"].ToString() == "F")
            {
                lblDriverGender5.Text = "Female";
            }
            if (_driverList.Rows[4]["Salutation"].ToString() != null && _driverList.Rows[4]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation5.Saluation = _driverList.Rows[4]["Salutation"].ToString();
            }
            if (_driverList.Rows[4]["Surname"].ToString() != null && _driverList.Rows[4]["Surname"].ToString() != "")
            {
                txtDriverSurName5.Text = _driverList.Rows[4]["Surname"].ToString();
            }
            if (_driverList.Rows[4]["GivenName"].ToString() != null && _driverList.Rows[4]["GivenName"].ToString() != "")
            {
                txtDriverGivenName5.Text = _driverList.Rows[4]["GivenName"].ToString();
            }
            if (_driverList.Rows[4]["IDType"].ToString() != null && _driverList.Rows[4]["IDType"].ToString() != "")
            {
                ddlDriverIdType5.IdType = _driverList.Rows[4]["IDType"].ToString();
            }
            if (_driverList.Rows[4]["IDNo"].ToString() != null && _driverList.Rows[4]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber5.Prefix = _driverList.Rows[4]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber5.Postfix = _driverList.Rows[4]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber5.IDNumber = _driverList.Rows[4]["IDNo"].ToString().Substring(1, 7);
            }
        }
    }

    private void CheckValidation()
    {
        txtFamilyName.Text = General.ClearScriptTag(txtFamilyName.Text);
        txtGivenName.Text = General.ClearScriptTag(txtGivenName.Text);
        txtPostCode.Text = General.ClearScriptTag(txtPostCode.Text);
        txtUnit1.Text = General.ClearScriptTag(txtUnit1.Text);
        txtUnit2.Text = General.ClearScriptTag(txtUnit2.Text);
        txtAddress.Text = General.ClearScriptTag(txtAddress.Text);
        txtEmpName.Text = General.ClearScriptTag(txtEmpName.Text);
        //txtTransInsVehicleNo.Text = General.ClearScriptTag(txtTransInsVehicleNo.Text);
        txtNCDReason.Text = General.ClearScriptTag(txtNCDReason.Text);
        txtVehicleNo.Text = General.ClearScriptTag(txtVehicleNo.Text);
        txtPurchasePrice.Text = General.ClearScriptTag(txtPurchasePrice.Text);
        txtEngineNo.Text = General.ClearScriptTag(txtEngineNo.Text);
        txtChassisNo.Text = General.ClearScriptTag(txtChassisNo.Text);
        txtVMReason.Text = General.ClearScriptTag(txtVMReason.Text);
        //txtOtherReason.Text = General.ClearScriptTag(txtOtherReason.Text);
        //txtBank.Text = General.ClearScriptTag(txtBank.Text);
        //txtChequeNo.Text = General.ClearScriptTag(txtChequeNo.Text);
        txtNameoftheCard.Text = General.ClearScriptTag(txtNameoftheCard.Text);
        txtIssuingBank.Text = General.ClearScriptTag(txtIssuingBank.Text);
        txtCardNo1.Text = General.ClearScriptTag(txtCardNo1.Text);
        txtCardNo2.Text = General.ClearScriptTag(txtCardNo2.Text);
        txtCardNo3.Text = General.ClearScriptTag(txtCardNo3.Text);
        txtCardNo4.Text = General.ClearScriptTag(txtCardNo4.Text);

        txtNatureofAccident.Text = General.ClearScriptTag(txtNatureofAccident.Text);
        txtNatureofAccidentDriver1.Text = General.ClearScriptTag(txtNatureofAccidentDriver1.Text);
        txtNatureofAccidentDriver2.Text = General.ClearScriptTag(txtNatureofAccidentDriver2.Text);
        txtNatureofAccidentDriver3.Text = General.ClearScriptTag(txtNatureofAccidentDriver3.Text);
        txtNatureofAccidentDriver4.Text = General.ClearScriptTag(txtNatureofAccidentDriver4.Text);
        txtNatureofAccidentDriver5.Text = General.ClearScriptTag(txtNatureofAccidentDriver5.Text);


        txtLicenceRevokedReason.Text = General.ClearScriptTag(txtLicenceRevokedReason.Text);
        txtLicRevokReason1.Text = General.ClearScriptTag(txtLicRevokReason1.Text);
        txtLicRevokReason2.Text = General.ClearScriptTag(txtLicRevokReason2.Text);
        txtLicRevokReason3.Text = General.ClearScriptTag(txtLicRevokReason3.Text);
        txtLicRevokReason4.Text = General.ClearScriptTag(txtLicRevokReason4.Text);
        txtLicRevokReason5.Text = General.ClearScriptTag(txtLicRevokReason5.Text);
        //txtCardExpiryMonth.Text = General.ClearScriptTag(txtCardExpiryMonth.Text);
        //txtCardExpiryYear.Text = General.ClearScriptTag(txtCardExpiryYear.Text);

        //#region Insurance Transferred
        //if (rdoYesInsuranceTransferred.Checked)
        //{
        //    rfvTransInsuranceCompany.Enabled = true;
        //    rfvTransInsVehicleNo.Enabled = true;
        //}
        //else
        //{
        //    rfvTransInsuranceCompany.Enabled = false;
        //    rfvTransInsVehicleNo.Enabled = false;
        //}
        //#endregion

        #region Licence Revoked
        if (rdoYesLicenceRevoked.Checked)
        {
            rfvYearofRevoked.Enabled = true;
            rfvLicenceRevokedReason.Enabled = true;
        }
        else
        {
            rfvYearofRevoked.Enabled = false;
            rfvLicenceRevokedReason.Enabled = false;
        }

        #endregion
        #region YesVechicle Modification
        if (rdoYesVechicleModification.Checked)
        {
            rfvVMReason.Enabled = true;
        }
        else
        {
            rfvVMReason.Enabled = false;
        }
        #endregion

        #region Hire Purchase
        if (rdoYesHirePurchase.Checked)
        {
            rfvHirePurchaseCompany.Enabled = true;
        }
        else
        {
            rfvHirePurchaseCompany.Enabled = false;
        }
        #endregion

        #region NCD

        if (ddlNCDReason.SelectedItem.Text == "Others")
        {
            rfvNCDReason.Enabled = true;
        }
        else
        {
            rfvNCDReason.Enabled = false;
        }
        #endregion

        #region Driver
        //Driver 1
        if (rfvRevoked1.Enabled == true)
        {
            if (rdoYesRevoked1.Checked)
            {
                rfvYearofRevokedDriver1.Enabled = true;
                rfvLicRevokReason1.Enabled = true;
            }
            else
            {
                rfvYearofRevokedDriver1.Enabled = false;
                rfvLicRevokReason1.Enabled = false;
            }
        }
        else
        {
            rfvYearofRevokedDriver1.Enabled = false;
            rfvLicRevokReason1.Enabled = false;
        }

        if (rfvDriverClaim1.Enabled == true)
        {
            if (rdoYesDriverClaim1.Checked)
            {
                ddlDateofAccidentDriver1.IsEnableValidation(true);
                rfvNatureofAccidentDriver1.Enabled = true;
                rfvClaimAmountDriver1.Enabled = true;
                revClaimAmountDriver1.Enabled = true;
                rfvTyeofClaimDriver1.Enabled = true;
            }
            else
            {
                ddlDateofAccidentDriver1.IsEnableValidation(false);
                rfvNatureofAccidentDriver1.Enabled = false;
                rfvClaimAmountDriver1.Enabled = false;
                revClaimAmountDriver1.Enabled = false;
                rfvTyeofClaimDriver1.Enabled = false;
            }
        }
        else
        {
            ddlDateofAccidentDriver1.IsEnableValidation(false);
            rfvNatureofAccidentDriver1.Enabled = false;
            rfvClaimAmountDriver1.Enabled = false;
            revClaimAmountDriver1.Enabled = false;
            rfvTyeofClaimDriver1.Enabled = false;
        }

        //Driver 2
        if (rfvRevoked2.Enabled == true)
        {
            if (rdoYesRevoked2.Checked)
            {
                rfvYearofRevokedDriver2.Enabled = true;
                rfvLicRevokReason2.Enabled = true;
            }
            else
            {
                rfvYearofRevokedDriver2.Enabled = false;
                rfvLicRevokReason2.Enabled = false;
            }
        }
        else
        {
            rfvYearofRevokedDriver2.Enabled = false;
            rfvLicRevokReason2.Enabled = false;
        }

        if (rfvDriverClaim2.Enabled == true)
        {
            if (rdoYesDriverClaim2.Checked)
            {
                ddlDateofAccidentDriver2.IsEnableValidation(true);
                rfvNatureofAccidentDriver2.Enabled = true;
                rfvClaimAmountDriver2.Enabled = true;
                revClaimAmountDriver2.Enabled = true;
                rfvTyeofClaimDriver2.Enabled = true;
            }
            else
            {
                ddlDateofAccidentDriver2.IsEnableValidation(false);
                rfvNatureofAccidentDriver2.Enabled = false;
                rfvClaimAmountDriver2.Enabled = false;
                revClaimAmountDriver2.Enabled = false;
                rfvTyeofClaimDriver2.Enabled = false;
            }
        }
        else
        {
            ddlDateofAccidentDriver2.IsEnableValidation(false);
            rfvNatureofAccidentDriver2.Enabled = false;
            rfvClaimAmountDriver2.Enabled = false;
            revClaimAmountDriver2.Enabled = false;
            rfvTyeofClaimDriver2.Enabled = false;
        }

        //Driver 3
        if (rfvRevoked3.Enabled == true)
        {
            if (rdoYesRevoked3.Checked)
            {
                rfvYearofRevokedDriver1.Enabled = true;
                rfvLicRevokReason1.Enabled = true;
            }
            else
            {
                rfvYearofRevokedDriver3.Enabled = false;
                rfvLicRevokReason3.Enabled = false;
            }
        }
        else
        {
            rfvYearofRevokedDriver3.Enabled = false;
            rfvLicRevokReason3.Enabled = false;
        }

        if (rfvDriverClaim3.Enabled == true)
        {
            if (rdoYesDriverClaim3.Checked)
            {
                ddlDateofAccidentDriver3.IsEnableValidation(true);
                rfvNatureofAccidentDriver3.Enabled = true;
                rfvClaimAmountDriver3.Enabled = true;
                revClaimAmountDriver3.Enabled = true;
                rfvTyeofClaimDriver3.Enabled = true;
            }
            else
            {
                ddlDateofAccidentDriver3.IsEnableValidation(false);
                rfvNatureofAccidentDriver3.Enabled = false;
                rfvClaimAmountDriver3.Enabled = false;
                revClaimAmountDriver3.Enabled = false;
                rfvTyeofClaimDriver3.Enabled = false;
            }
        }
        else
        {
            ddlDateofAccidentDriver3.IsEnableValidation(false);
            rfvNatureofAccidentDriver3.Enabled = false;
            rfvClaimAmountDriver3.Enabled = false;
            revClaimAmountDriver3.Enabled = false;
            rfvTyeofClaimDriver3.Enabled = false;
        }

        //Driver 4
        if (rfvRevoked4.Enabled == true)
        {
            if (rdoYesRevoked4.Checked)
            {
                rfvYearofRevokedDriver4.Enabled = true;
                rfvLicRevokReason4.Enabled = true;
            }
            else
            {
                rfvYearofRevokedDriver4.Enabled = false;
                rfvLicRevokReason4.Enabled = false;
            }
        }
        else
        {
            rfvYearofRevokedDriver4.Enabled = false;
            rfvLicRevokReason4.Enabled = false;
        }
        if (rfvDriverClaim4.Enabled == true)
        {
            if (rdoYesDriverClaim4.Checked)
            {
                ddlDateofAccidentDriver4.IsEnableValidation(true);
                rfvNatureofAccidentDriver4.Enabled = true;
                rfvClaimAmountDriver4.Enabled = true;
                revClaimAmountDriver4.Enabled = true;
                rfvTyeofClaimDriver4.Enabled = true;
            }
            else
            {
                ddlDateofAccidentDriver4.IsEnableValidation(false);
                rfvNatureofAccidentDriver4.Enabled = false;
                rfvClaimAmountDriver4.Enabled = false;
                revClaimAmountDriver4.Enabled = false;
                rfvTyeofClaimDriver4.Enabled = false;
            }
        }
        else
        {
            ddlDateofAccidentDriver4.IsEnableValidation(false);
            rfvNatureofAccidentDriver4.Enabled = false;
            rfvClaimAmountDriver4.Enabled = false;
            revClaimAmountDriver4.Enabled = false;
            rfvTyeofClaimDriver4.Enabled = false;
        }

        //Driver 5
        if (rfvRevoked5.Enabled == true)
        {
            if (rdoYesRevoked5.Checked)
            {
                rfvYearofRevokedDriver5.Enabled = true;
                rfvLicRevokReason5.Enabled = true;
            }
            else
            {
                rfvYearofRevokedDriver5.Enabled = false;
                rfvLicRevokReason5.Enabled = false;
            }
        }
        else
        {
            rfvYearofRevokedDriver5.Enabled = false;
            rfvLicRevokReason5.Enabled = false;
        }

        if (rfvDriverClaim5.Enabled == true)
        {
            if (rdoYesDriverClaim5.Checked)
            {
                ddlDateofAccidentDriver5.IsEnableValidation(true);
                rfvNatureofAccidentDriver5.Enabled = true;
                rfvClaimAmountDriver5.Enabled = true;
                revClaimAmountDriver5.Enabled = true;
                rfvTyeofClaimDriver5.Enabled = true;
            }
            else
            {
                ddlDateofAccidentDriver5.IsEnableValidation(false);
                rfvNatureofAccidentDriver5.Enabled = false;
                rfvClaimAmountDriver5.Enabled = false;
                revClaimAmountDriver5.Enabled = false;
                rfvTyeofClaimDriver5.Enabled = false;
            }
        }
        else
        {
            ddlDateofAccidentDriver5.IsEnableValidation(false);
            rfvNatureofAccidentDriver5.Enabled = false;
            rfvClaimAmountDriver5.Enabled = false;
            revClaimAmountDriver5.Enabled = false;
            rfvTyeofClaimDriver5.Enabled = false;
        }
        #endregion
        //#region Purpose of Use
        //if (rdoOthers.Checked)
        //{
        //    rfvOtherReason.Enabled = true;
        //}
        //else
        //{
        //    rfvOtherReason.Enabled = false;
        //}
        //#endregion

        //#region Payment Mode
        //if (rdoCashorNets.Checked)
        //{
        //    rfvBank.Enabled = false;
        //    rfvChequeNo.Enabled = false;
        //    revChequeNo.Enabled = false;
        //    rfvNameoftheCard.Enabled = false;
        //    rfvIssuingBank.Enabled = false;
        //    rfvCardNo1.Enabled = false;
        //    revCardNo1.Enabled = false;
        //    rfvCardNo2.Enabled = false;
        //    revCardNo2.Enabled = false;
        //    rfvCardNo3.Enabled = false;
        //    revCardNo3.Enabled = false;
        //    rfvCardNo4.Enabled = false;
        //    revCardNo4.Enabled = false;
        //    rfvCardExpiryMonth.Enabled = false;
        //    revCardExpiryMonth.Enabled = false;
        //    rfvCardExpiryYear.Enabled = false;
        //    revCardExpiryYear.Enabled = false;
        //    rfvCardType.Enabled = false;
        //}
        //else if (rdoCheque.Checked)
        //{
        //    rfvBank.Enabled = true;
        //    rfvChequeNo.Enabled = true;
        //    revChequeNo.Enabled = true;
        //    rfvNameoftheCard.Enabled = false;
        //    rfvIssuingBank.Enabled = false;
        //    rfvCardNo1.Enabled = false;
        //    revCardNo1.Enabled = false;
        //    rfvCardNo2.Enabled = false;
        //    revCardNo2.Enabled = false;
        //    rfvCardNo3.Enabled = false;
        //    revCardNo3.Enabled = false;
        //    rfvCardNo4.Enabled = false;
        //    revCardNo4.Enabled = false;
        //    rfvCardExpiryMonth.Enabled = false;
        //    revCardExpiryMonth.Enabled = false;
        //    rfvCardExpiryYear.Enabled = false;
        //    revCardExpiryYear.Enabled = false;
        //    rfvCardType.Enabled = false;
        //}
        //else if (rdoCreditCard.Checked)
        //{
        //    rfvBank.Enabled = false;
        //    rfvChequeNo.Enabled = false;
        //    revChequeNo.Enabled = false;
        //    rfvNameoftheCard.Enabled = true;
        //    rfvIssuingBank.Enabled = true;
        //    rfvCardNo1.Enabled = true;
        //    revCardNo1.Enabled = true;
        //    rfvCardNo2.Enabled = true;
        //    revCardNo2.Enabled = true;
        //    rfvCardNo3.Enabled = true;
        //    revCardNo3.Enabled = true;
        //    rfvCardNo4.Enabled = true;
        //    revCardNo4.Enabled = true;
        //    rfvCardExpiryMonth.Enabled = true;
        //    revCardExpiryMonth.Enabled = true;
        //    rfvCardExpiryYear.Enabled = true;
        //    revCardExpiryYear.Enabled = true;
        //    rfvCardType.Enabled = true;
        //}
        //#endregion

    }

    private void ProposalNotification()
    {
        string _strSql, _providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _Date, _Time, _InsuranceName, _RefNo;
        MyDatabase _db = new MyDatabase();
        DataTable _dtProvider = new DataTable();
        DataTable _dtInsurance = new DataTable();
        _Date = "";
        _Time = "";
        _RefNo = "";
        _strSql = "";
        _providerName = "";
        _providerEmail = "";
        _providerCCEmail = "";
        _providerBCCEmail = "";
        _InsuranceName = "Car Insurance";
        _strSql = "SELECT [CompanyName], [Email1] FROM tblProviderCompany WHERE ProviderCompanyId = " + Session[General.ProviderCompanyId].ToString();
        _dtProvider = _db.GetDataTable(_strSql);
        if (_dtProvider.Rows.Count > 0)
        {
            _providerName = _dtProvider.Rows[0]["CompanyName"].ToString() + " Insurance";
            //_providerEmail = _dtProvider.Rows[0]["Email1"].ToString();
            _providerEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_TO");
            _providerCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_CC");
            _providerBCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_BCC");
        }
        _strSql = "";
        _strSql = "SELECT CONVERT(VARCHAR,ModifiedDate,103) AS [Date], CONVERT(VARCHAR,ModifiedDate,108) AS [Time] ";
        _strSql += " FROM  tblCarMoreDetail_Hsbc WHERE CECarId = " + Session[General.CarId].ToString() + " ORDER BY ModifiedDate DESC";
        _dtInsurance = _db.GetDataTable(_strSql);
        if (_dtInsurance.Rows.Count > 0)
        {
            _Date = _dtInsurance.Rows[0]["Date"].ToString();
            _Time = _dtInsurance.Rows[0]["Time"].ToString();
        }
        //_RefNo = General.GetRefNumber("CI", _Date, Session[General.CarId].ToString());
        _RefNo = lblQRefNo.Text.Trim();
        if ((_dtProvider.Rows.Count > 0) && (_dtInsurance.Rows.Count > 0))
        {
            MyMailManager.SendProposalCompleteNotification(_providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _InsuranceName, _Date, _Time, _RefNo);
            
            //send with pdf
            //MyMailManager.SendProposalCompleteNotificationWithAttachment(_providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _InsuranceName, _Date, _Time, _RefNo, GeneratePDFProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId])));
        }

    }

    protected void GenerateProposalForm(Int64 RefID)
    {
        Label lblContent = new Label();
        string _fileName = "FileName";
        string _applicationdate = " : " + CE.Global.General.GetUTCDateTime().ToString("dd/MMM/yyyy") + " " + CE.Global.General.GetUTCDateTime().ToShortTimeString();
        string convertno = General.GetRefNumber(RefID);
        _fileName = "H" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h4>HSBC Insurance Singapore : Car Insurance - Proposal Form</h4></td><td colspan='2' align='right'>Application Date" + _applicationdate.ToString() + "    </td></tr></table>");

        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetHSBCProposal(RefID, "CI");
        string _html = "";
        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            string _name, _dob, _nationality, _nric, _maritalstatus, _mobile, _hoemphone, _officephone, _faxno, _unitno, _homeno, _address;
            string _postalcode, _gender, _empname, _email, _claimstatus, _divclaimstatus, _dd, _mm, _yy, _occupation, _claim1ststat, _claim1stend, claimamt1;
            string _claimcount1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent, _inscomp;
            string _ncdreson, _vehicleno, _makemodel, _cc, _enginetype, _regyear, _offpeakcar, _bodytype, _purchaseprice, _engineno, _chassisno;
            string _insstartdate, _insenddate, _hp, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _drname1, _drdob1, _drdd1, _drmm1, _dryy1, _drocc1, _drnobus1;
            string _drname2, _drdob2, _drdd2, _drmm2, _dryy2, _drocc2, _drnobus2, _drname3, _drdob3, _drdd3, _drmm3, _dryy3, _drocc3, _drnobus3;
            string _drname4, _drdob4, _drdd4, _drmm4, _dryy4, _drocc4, _drnobus4, _drname5, _drdob5, _drdd5, _drmm5, _dryy5, _drocc5, _drnobus5;
            string _adddriver, _drcount, _installmenttype,  _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _planname, _annualpremium;
            string _isyoungdriver, _iscompanycar, _isdeclined, _isnoncdprotect, _isCOE, _isSocialPurpose;
            DateTime _dofb, _isdate, _iedate, _drdofb1, _drdofb2, _drdofb3, _drdofb4, _drdofb5;

            _drname1 = ""; _drdob1 = ""; _drdd1 = ""; _drmm1 = ""; _dryy1 = ""; _drocc1 = ""; _drnobus1 = "";
            _drname2 = ""; _drdob2 = ""; _drdd2 = ""; _drmm2 = ""; _dryy2 = ""; _drocc2 = ""; _drnobus2 = "";
            _drname3 = ""; _drdob3 = ""; _drdd3 = ""; _drmm3 = ""; _dryy3 = ""; _drocc3 = ""; _drnobus3 = "";
            _drname4 = ""; _drdob4 = ""; _drdd4 = ""; _drmm4 = ""; _dryy4 = ""; _drocc4 = ""; _drnobus4 = "";
            _drname5 = ""; _drdob5 = ""; _drdd5 = ""; _drmm5 = ""; _dryy5 = ""; _drocc5 = ""; _drnobus5 = ""; _planname = ""; _annualpremium = "";
            _adddriver = ""; _drcount = ""; _installmenttype = ""; _nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";
            _isyoungdriver = ""; _iscompanycar = ""; _isdeclined = ""; _isnoncdprotect = ""; _isCOE = ""; _isSocialPurpose = "";

            _name = _dsProposal.Tables[0].Rows[0]["FamilyName"].ToString() + " " + _dsProposal.Tables[0].Rows[0]["GivenName"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString().Substring(2, 2);
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpName"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString() + " / " + _dsProposal.Tables[0].Rows[0]["NofBusi"].ToString();
            _hoemphone = _dsProposal.Tables[0].Rows[0]["HomePhoneNo"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _faxno = _dsProposal.Tables[0].Rows[0]["FaxNo"].ToString();

            _isyoungdriver = _dsProposal.Tables[0].Rows[0]["Info1"].ToString();
            _iscompanycar = _dsProposal.Tables[0].Rows[0]["Info2"].ToString();
            _isdeclined = _dsProposal.Tables[0].Rows[0]["Info3"].ToString();
            _isnoncdprotect = _dsProposal.Tables[0].Rows[0]["Info4"].ToString();
            _isCOE = _dsProposal.Tables[0].Rows[0]["Info5"].ToString();
            _isSocialPurpose = _dsProposal.Tables[0].Rows[0]["Info6"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
                _divclaimstatus = "none";
            }
            else
            {
                _claimstatus = "Yes";
                _divclaimstatus = "block";
            }
            if (_dsProposal.Tables[2].Rows.Count > 0)
            {
                _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();

                if (_inscomp.ToString() == "")
                {
                    _ncdstatus = "Not Applicable";
                }
                else
                {
                    _ncdstatus = "Yes";
                }
            }
            else
            {
                _ncdstatus = "No";
                _inscomp = "Not Applicable";
            }

            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
            if (_ncdreson.ToString() == "Others")
            {
                _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
            }
            else if (_ncdreson.ToString() == "-1")
            {
                _ncdreson = "Not Applicable";
            }

            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
                _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
                _divclaimstatus = "block";
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";
                _claimcount1 = "0";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";
                _divclaimstatus = "none";

                _ncdpercent = "0%";
            }
            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "10%";
            }
            else
            {
                if (_claimstatus == "No")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "0")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "1")
                {
                    _ncdpercent = OneTimesNCD(_ncdpercent);
                }
                else
                {
                    _ncdpercent = "0%";
                }
            }
            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _regyear = _dsProposal.Tables[0].Rows[0]["RegYear"].ToString();
            _makemodel = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _offpeakcar = _dsProposal.Tables[0].Rows[0]["Offbeak"].ToString();
            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _enginetype = _dsProposal.Tables[0].Rows[0]["EngineType"].ToString();
            _bodytype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _purchaseprice = _dsProposal.Tables[0].Rows[0]["PurchasePrice"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString().Substring(2, 2);
            //_insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString().Substring(2, 2);
            //_insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hp.ToString() == "")
                {
                    _hp = "Not Applicable";
                }
            }
            else
            {
                _hp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "Yes";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "No";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drdofb1 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[0]["DOB"].ToString());
                    _drdd1 = _drdofb1.Day.ToString("00");
                    _drmm1 = _drdofb1.Month.ToString("00");
                    _dryy1 = _drdofb1.Year.ToString().Substring(2, 2);
                    //_drdob1 = _drdd1 + "/" + _drmm1 + "/" + _dryy1;
                    _drdob1 = _dsProposal.Tables[4].Rows[0]["DOB"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drnobus1 = _dsProposal.Tables[4].Rows[0]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drdofb2 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[1]["DOB"].ToString());
                    _drdd2 = _drdofb2.Day.ToString("00");
                    _drmm2 = _drdofb2.Month.ToString("00");
                    _dryy2 = _drdofb2.Year.ToString().Substring(2, 2);
                    //_drdob2 = _drdd2 + "/" + _drmm2 + "/" + _dryy2;
                    _drdob2 = _dsProposal.Tables[4].Rows[1]["DOB"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drnobus2 = _dsProposal.Tables[4].Rows[1]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drdofb3 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[2]["DOB"].ToString());
                    _drdd3 = _drdofb3.Day.ToString("00");
                    _drmm3 = _drdofb3.Month.ToString("00");
                    _dryy3 = _drdofb3.Year.ToString().Substring(2, 2);
                    //_drdob3 = _drdd3 + "/" + _drmm3 + "/" + _dryy3;
                    _drdob3 = _dsProposal.Tables[4].Rows[2]["DOB"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drnobus3 = _dsProposal.Tables[4].Rows[2]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drdofb4 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[3]["DOB"].ToString());
                    _drdd4 = _drdofb4.Day.ToString("00");
                    _drmm4 = _drdofb4.Month.ToString("00");
                    _dryy4 = _drdofb4.Year.ToString().Substring(2, 2);
                    //_drdob4 = _drdd4 + "/" + _drmm4 + "/" + _dryy4;
                    _drdob4 = _dsProposal.Tables[4].Rows[3]["DOB"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drnobus4 = _dsProposal.Tables[4].Rows[3]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drdofb5 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[4]["DOB"].ToString());
                    _drdd5 = _drdofb5.Day.ToString("00");
                    _drmm5 = _drdofb5.Month.ToString("00");
                    _dryy5 = _drdofb5.Year.ToString().Substring(2, 2);
                    //_drdob5 = _drdd5 + "/" + _drmm5 + "/" + _dryy5;
                    _drdob5 = _dsProposal.Tables[4].Rows[4]["DOB"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drnobus5 = _dsProposal.Tables[4].Rows[4]["DvrBusiness"].ToString();
                }
            }

            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefID, 23, "CI");
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                //_ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                //_ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _ccexmm = "XX";
                _ccexyy = "XX";
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();

                _ccno = "XXXX XXXX XXXX XXXX";
                _installmenttype = _dsPayment.Tables[0].Rows[0]["Installment"].ToString();
                //if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                //    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                //else
                //    _ccno = "";
            }

            _html = "<table><tr><td width='25%'>Plan Name</td><td>" + _planname + "</td><td colspan='2' align='right'>Annual Premium : $" + _annualpremium.ToString() + "</td></tr></table>";
            _html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Reference Number</td>"
                     + "<td width='50%' align='left'>" + "H" + convertno + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name (as shown in NRIC / Passport)</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                      + "<tr>"
                     + "<td width='50%' align='left'>Nationality</td>"
                     + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>NRIC Number</td>"
                     + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                     + "</tr>"


                     + "<tr>"
                     + "<td width='50%' align='left'>Marital Status</td>"
                     + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
                     + "</tr>"

                      + "<tr>"
                     + "<td width='50%' align='left'>Mobile No</td>"
                     + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Residential No</td>"
                     + "<td width='50%' align='left'>" + _hoemphone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left'>Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Postal Code</td>"
                     + "<td width='50%' align='left'>" + _postalcode.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Occupation / Nature of Business</td>"
                     + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan = '2'></td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name of employer</td>"
                     + "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date of Birth</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Gender</td>"
                     + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'> </td>"
                     + "<td width='50%' align='left'> </td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'> </td>"
                     + "<td width='50%' align='left'></td>"
                     + "</tr>"


                     + "<tr>"
                     + "<td width='50%' align='left'>Office No</td>"
                     + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Fax No</td>"
                     + "<td width='50%' align='left'>" + _faxno.ToString() + "</td>"
                     + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'></td>"
                    + "<td width='50%' align='left'></td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'></td>"
                    + "<td width='50%' align='left'></td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'></td>"
                    + "<td width='50%' align='left'></td>"
                    + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Email Address</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                     + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'></td>"
                    + "<td width='50%' align='left'></td>"
                    + "</tr>"

                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2' align='left'> At fault motor claims experiences, please provide the reason : " + _claimstatus.ToString() + "</td>"
                     + "</tr>"

                     + "<div style='display:" + _divclaimstatus + ";'>"
                     + "<tr>"
                     + "<td colspan='2'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>";
            if (claimamt1.ToString() == "0")
            {
                _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _claim1ststat.ToString() + " to " + _claim1stend.ToString() + "</td>"
                + "<td style='width: 25%' align='left'> Claim Amount</td>"
                + "<td style='width: 25%' align='left'>" + claimamt1.ToString() + "</td></tr>";
            }
            if (claimamt2.ToString() == "0")
            {
                _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim2ndstat.ToString() + " to " + _claim2ndend.ToString() + "</td>"
                + "<td style='width: 25%' align='left'> Claim Amount</td>"
                + "<td style='width: 25%' align='left'>" + claimamt2.ToString() + "</td></tr>";
            }
            if (claimamt3.ToString() == "0")
            {
                _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim3rdstat.ToString() + " to " + _claim3rdend.ToString() + "</td>"
                + "<td style='width: 25%' align='left'> Claim Amount</td>"
                + "<td style='width: 25%' align='left'>" + claimamt3.ToString() + "</td></tr>";
            }
            _html += "</table>"
             + "</td>"
             + "</tr>"
             + "</div>"

             + "<tr>"
             + "<td colspan='2' align='left'>No Claim Discount(NCD) to be transferred to this insurance policy : " + _ncdstatus.ToString() + "</td>"
             + "</tr>"

             + "<tr>"
             + "<td colspan='2'>"
             + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

             + "<tr><td style='width:25%' align='left'>NCD on next renewal (%)</td>"
             + "<td style='width: 25%' align='left'>" + _ncdpercent.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Insurance Company</td>"
             + "<td style='width: 25%' align='left'>" + _inscomp.ToString() + "</td></tr>"

             + "<tr>"
             + "<td colspan='4' align='left'>If NCD is nil or 10% with no claims experiences, please provide reason : " + _ncdreson.ToString() + "</td>"
             + "</tr>"
             + "<tr><td colspan='4' align='left'></td></tr>"

             + "<tr><td colspan='4' align='left'><b>Details of motor car to be insured</b></td></tr>"

             + "<tr><td style='width:25%' align='left'>Registration No</td>"
             + "<td style='width: 25%' align='left'>" + _vehicleno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Year of Registration</td>"
             + "<td style='width: 25%' align='left'>" + _regyear.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Make and Model</td>"
             + "<td style='width: 25%' align='left'>" + _makemodel.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Off peak car?</td>"
             + "<td style='width: 25%' align='left'>" + _offpeakcar.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Cubic capacity (CC)</td>"
             + "<td style='width: 25%' align='left'>" + _cc.ToString() + "cc</td>"
             + "<td style='width: 25%' align='left'>Engine Type</td>"
             + "<td style='width: 25%' align='left'>" + _enginetype.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Type of Body</td>"
             + "<td style='width: 25%' align='left'>" + _bodytype.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Purchase price</td>"
             + "<td style='width: 25%' align='left'>" + _purchaseprice.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Engine Number</td>"
             + "<td style='width: 25%' align='left' >" + _engineno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Chassis Number</td>"
             + "<td style='width: 25%' align='left'>" + _chassisno.ToString() + "</td></tr>"

             + "<tr>"
             + "<td colspan='2' align='left'>Name of hire purchase owner(s), if any</td>"
             + "<td colspan='2' align='left'>" + _hp.ToString() + "</td>"
             + "</tr>"
             + "<tr><td colspan='4' align='left'></td></tr>"

             + "<tr><td colspan='4' align='left'><b>Details of insurance required</b></td></tr>";

            DateTime dtStart = Convert.ToDateTime(_insstartdate);
            DateTime dtEnd = Convert.ToDateTime(_insenddate);

            _html += "<tr><td colspan='3' align='left'>Period of insurance required</td>"
             + "<td align='left'>From " + dtStart.ToString("dd/MMM/yy") + " To " + dtEnd.ToString("dd/MMM/yy") + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>From</td>"
                //+ "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
                //+ "<td style='width: 25%' align='left'>To midnight of</td>"
                //+ "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td></tr>"

           + "<tr><td colspan='3' align='left'>Would the car be driven by any Young and/or Inexperienced driver (aged below 26 years and/or has a full driving license for less than 2 years) ?</td>"
           + "<td align='left'>" + IsYesNo(_isyoungdriver) + "</td></tr>"

           + "<tr><td colspan='3' align='left'>Company Registered Car</td>"
           + "<td align='left'>" + IsYesNo(_iscompanycar) + "</td></tr>"

           + "<tr><td colspan='3' align='left'>Has any insurance company ever declined your proposal, cancelled or refused to renew your policy during the last 3 years?</td>"
           + "<td align='left'>" + IsYesNo(_isdeclined) + "</td></tr>"

           + "<tr><td colspan='3' align='left'>I opt to insure with No Claim Discount Protection (Applicable to 50% NCD only)</td>"
           + "<td align='left'>" + IsYesNo(_isnoncdprotect) + "</td></tr>"

           + "<tr><td colspan='3' align='left'>I opt to insure without COE/PARF</td>"
           + "<td align='left'>" + IsYesNo(_isCOE) + "</td></tr>"

           + "<tr><td colspan='3' align='left'>  Is the car being used for social, domestic and pleasure purposes and business of proposer, proposer's employer or partner?</td>"
          + "<td align='left'>" + IsYesNo(_isSocialPurpose) + "</td></tr>"

           + "<tr><td align='left' colspan='4' ></td></tr>";


            _html += "<tr><td colspan='4' align='left'><b>Details of main driver / named driver : </b>" + _adddriver.ToString() + "</td></tr>";

            if (Convert.ToInt16(_drcount) > 0)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 1</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus1.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 1)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 2</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob2.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus2.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 2)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 3</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob3.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus3.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 3)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 4</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob4.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus4.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 4)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 5</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob5.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus5.ToString() + "</td></tr>";
            }
            _html += "<tr><td colspan='4' align='left'></td></tr>"
              + "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
            + "<tr><td style='width:25%' align='left'>Name of the Card</td>"
            + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
            + "<td style='width: 25%' align='left'>Issuing Bank</td>"
            + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

            + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
            + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
            + "<td style='width: 25%' align='left'>Card expiry date</td>"
            + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

            + "<tr><td style='width:25%' align='left'>Type of Card</td>"
            + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"

            + "</table>"
            + "</td>"
            + "</tr>"

            + "</table>"
            + "</div></div>";


            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string _filePath = GetFilePath();
            string filename = _fileName + ".xls";

            string[] filecontent = new string[1];
            filecontent[0] = strText + lblContent.Text.ToString();
            //myio.WriteNewFile(AppDomain.CurrentDomain.BaseDirectory + "car_insurance\\proposalforms\\", _fileName + ".xls", filecontent);
            //myio.WriteNewFile(AppDomain.CurrentDomain.BaseDirectory + "exceloutput\\", _fileName + ".xls", filecontent);
            myio.WriteNewFile(_filePath, filename, filecontent);

            //SEND MAIL
            string _providerEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_TO");
            string _providerCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_CC");
            string _providerBCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_BCC");


            //string _providerEmail = "cherylmae.lanot@teledirect.com.sg";
            string[] filelist = new string[1];
            //string _excelfile = Server.MapPath("proposalforms/" + _fileName + ".xls");
            //string _excelfile = Server.MapPath("~/exceloutput/" + _fileName + ".xls");
            string _excelfile = _filePath + filename;

            filelist[0] = _excelfile;
            string _refid = "H" + convertno;
            MyMailManager.SendCarProposalAttachment("HSBC Insurance", _providerEmail, _providerCCEmail, _providerBCCEmail, "", CE.Global.General.GetUTCDateTime().ToShortDateString(), CE.Global.General.GetUTCDateTime().ToShortTimeString(), _refid, "HSBC", filelist);
        }

    }

    private string GetFilePath()
    {
        string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
        _filePath += "exceloutput\\hsbc\\";
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        string _todaydate = CE.Global.General.GetUTCDateTime().ToString("yyyyMMMdd");
        if (!_myIO.CheckDirectory(_filePath + _todaydate))
        {
            if (_myIO.CreateDirectory(_filePath, _todaydate))
            {
                _filePath += _todaydate + "\\";
            }
        }
        else
        {
            _filePath += _todaydate + "\\";
        }

        return _filePath;
    }

    private string NoNCD(string NCD)
    {
        string _ncd = "";
        if (NCD == "0")
        {
            _ncd = "10%";
        }
        else if (NCD == "10")
        {
            _ncd = "20%";
        }
        else if (NCD == "20")
        {
            _ncd = "30%";
        }
        else if (NCD == "30")
        {
            _ncd = "40%";
        }
        else if (NCD == "40" || NCD == "50")
        {
            _ncd = "50%";
        }
        return _ncd;
    }

    private string OneTimesNCD(string NCD)
    {
        string _ncd = "";
        if (NCD == "0" || NCD == "10" || NCD == "20" || NCD == "30")
        {
            _ncd = "0%";
        }
        else if (NCD == "40")
        {
            _ncd = "10%";
        }
        else if (NCD == "50")
        {
            _ncd = "20%";
        }
        return _ncd;
    }

    private string IsYesNo(string option)
    {
        string IsYes = "Yes";

        if (option == "False")
            IsYes = "No";

        return IsYes;
    }

    private Int64 LogUserViewedHistory()
    {
        UserViewHistoryDB _userviewdb = new UserViewHistoryDB();
        return _userviewdb.LogViewedHistory("CI", Request, "Car Insurance HSBC proposal form.");
    }

    private PostCode GetPostCode(string strPostCode)
    {
        PostCode _postcode = new PostCode();
        PostCodeDB _postcodedb = new PostCodeDB();
        _postcode = _postcodedb.GetPostCode(strPostCode);
        _postcodedb = null;
        return _postcode;
    }

    private void ChangeValidationEffectServerSide(string strValidationGroup)
    {
        #region Proposal Details
        //Salutation
        ddlSalutation.ChangeValidationEffectServerSide(strValidationGroup);
        //Family Name
        if (rfvFamilyName.Enabled && rfvFamilyName.ValidationGroup == strValidationGroup)
        {
            rfvFamilyName.Validate();
            if (rfvFamilyName.IsValid == false)
            {
                txtFamilyName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtFamilyName.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtFamilyName.ControlStyle.CssClass = "";
        }

        if (revFamilyName.Enabled && revFamilyName.ValidationGroup == strValidationGroup)
        {
            if (rfvFamilyName.IsValid)
            {
                revFamilyName.Validate();
                if (revFamilyName.IsValid == false)
                {
                    txtFamilyName.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtFamilyName.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtFamilyName.ControlStyle.CssClass = "";
        }
        //Given Name
        if (rfvGivenName.Enabled && rfvGivenName.ValidationGroup == strValidationGroup)
        {
            rfvGivenName.Validate();
            if (rfvGivenName.IsValid == false)
            {
                txtGivenName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtGivenName.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtGivenName.ControlStyle.CssClass = "";
        }

        if (revGivenName.Enabled && revGivenName.ValidationGroup == strValidationGroup)
        {
            if (rfvGivenName.IsValid)
            {
                revGivenName.Validate();
                if (revGivenName.IsValid == false)
                {
                    txtGivenName.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtGivenName.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtGivenName.ControlStyle.CssClass = "";
        }
        //Postal Code
        if (rfvPostCode.Enabled && rfvPostCode.ValidationGroup == strValidationGroup)
        {
            rfvPostCode.Validate();
            if (rfvPostCode.IsValid == false)
            {
                txtPostCode.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPostCode.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        if (revPostCode.Enabled && revPostCode.ValidationGroup == strValidationGroup)
        {
            if (rfvPostCode.IsValid)
            {
                revPostCode.Validate();
                if (revPostCode.IsValid == false)
                {
                    txtPostCode.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtPostCode.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        //Unit No
        if (rfvUnit1.Enabled && rfvUnit1.ValidationGroup == strValidationGroup)
        {
            rfvUnit1.Validate();
            if (rfvUnit1.IsValid == false)
            {
                txtUnit1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit1.ControlStyle.CssClass = "";
        }

        //Home No
        if (rfvUnit2.Enabled && rfvUnit2.ValidationGroup == strValidationGroup)
        {
            rfvUnit2.Validate();
            if (rfvUnit2.IsValid == false)
            {
                txtUnit2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit2.ControlStyle.CssClass = "";
        }

        //Address
        if (rfvAddress.Enabled && rfvAddress.ValidationGroup == strValidationGroup)
        {
            rfvAddress.Validate();
            if (rfvAddress.IsValid == false)
            {
                txtAddress.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtAddress.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtAddress.ControlStyle.CssClass = "";
        }

        //if (revAddress.Enabled && revAddress.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvAddress.IsValid)
        //    {
        //        revAddress.Validate();
        //        if (revAddress.IsValid == false)
        //        {
        //            txtAddress.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtAddress.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtAddress.ControlStyle.CssClass = "";
        //}

        //Applicant's NRIC Number
        ddlIdNumber.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Nationality
        ddlNationality.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Mobile Number
        txtMobileNo.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Home Phone Number
        txtResidentialPhoneNo.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Office Number
        txtOfficePhoneNo.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Fax Number
        txtFaxNo.ChangeValidationEffectServerSide(strValidationGroup);
        //Emp Name
        //if (rfvEmpName.Enabled && rfvEmpName.ValidationGroup == strValidationGroup)
        //{
        //    rfvEmpName.Validate();
        //    if (rfvEmpName.IsValid == false)
        //    {
        //        txtEmpName.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtEmpName.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtEmpName.ControlStyle.CssClass = "";
        //}

        if (revEmpName.Enabled && revEmpName.ValidationGroup == strValidationGroup)
        {
            //if (rfvEmpName.IsValid)
            //{
            revEmpName.Validate();
            if (revEmpName.IsValid == false)
            {
                txtEmpName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEmpName.ControlStyle.CssClass = "";
            }
            //}
        }
        else
        {
            txtEmpName.ControlStyle.CssClass = "";
        }

        if (rfvNCDReasonDdl.Enabled && rfvNCDReasonDdl.ValidationGroup == strValidationGroup)
        {
            rfvNCDReasonDdl.Validate();
            if (rfvNCDReasonDdl.IsValid == false)
            {
                ddlNCDReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlNCDReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlNCDReason.ControlStyle.CssClass = "";
        }

        //Insurance Transferred
        //if (rfvInsuranceTransferred.Enabled && rfvInsuranceTransferred.ValidationGroup == strValidationGroup)
        //{
        //    rfvInsuranceTransferred.Validate();
        //    if (rfvInsuranceTransferred.IsValid == false)
        //    {
        //        lblYesInsuranceTransferred.ControlStyle.CssClass = "validationError";
        //        lblNoInsuranceTransferred.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        lblYesInsuranceTransferred.ControlStyle.CssClass = "";
        //        lblNoInsuranceTransferred.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    lblYesInsuranceTransferred.ControlStyle.CssClass = "";
        //    lblNoInsuranceTransferred.ControlStyle.CssClass = "";
        //}

        //Licence Revoked
        if (rfvLicenceRevoked.Enabled && rfvLicenceRevoked.ValidationGroup == strValidationGroup)
        {
            rfvLicenceRevoked.Validate();
            if (rfvLicenceRevoked.IsValid == false)
            {
                lblYesLicenceRevoked.ControlStyle.CssClass = "validationError";
                lblNoLicenceRevoked.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesLicenceRevoked.ControlStyle.CssClass = "";
                lblNoLicenceRevoked.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesLicenceRevoked.ControlStyle.CssClass = "";
            lblNoLicenceRevoked.ControlStyle.CssClass = "";
        }

        if (rfvYearofRevoked.Enabled && rfvYearofRevoked.ValidationGroup == strValidationGroup)
        {
            rfvYearofRevoked.Validate();
            if (rfvYearofRevoked.IsValid == false)
            {
                ddlYearofRevoked.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofRevoked.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofRevoked.ControlStyle.CssClass = "";
        }

        if (rfvLicenceRevokedReason.Enabled && rfvLicenceRevokedReason.ValidationGroup == strValidationGroup)
        {
            rfvLicenceRevokedReason.Validate();
            if (rfvLicenceRevokedReason.IsValid == false)
            {
                txtLicenceRevokedReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtLicenceRevokedReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtLicenceRevokedReason.ControlStyle.CssClass = "";
        }

        if (rfvYearofObtained.Enabled && rfvYearofObtained.ValidationGroup == strValidationGroup)
        {
            rfvYearofObtained.Validate();
            if (rfvYearofObtained.IsValid == false)
            {
                ddlYearofObtained.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofObtained.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofObtained.ControlStyle.CssClass = "";
        }

        ddlDateofAccident.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvNatureofAccident.Enabled && rfvNatureofAccident.ValidationGroup == strValidationGroup)
        {
            rfvNatureofAccident.Validate();
            if (rfvNatureofAccident.IsValid == false)
            {
                txtNatureofAccident.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNatureofAccident.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNatureofAccident.ControlStyle.CssClass = "";
        }

        if (rfvTyeofClaim.Enabled && rfvTyeofClaim.ValidationGroup == strValidationGroup)
        {
            rfvTyeofClaim.Validate();
            if (rfvTyeofClaim.IsValid == false)
            {
                ddlTyeofClaim.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTyeofClaim.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTyeofClaim.ControlStyle.CssClass = "";
        }

        #endregion

        #region Purticulas of Vehicle

        //TransInsuranceCompany
        if (rfvTransInsuranceCompany.Enabled && rfvTransInsuranceCompany.ValidationGroup == strValidationGroup)
        {
            rfvTransInsuranceCompany.Validate();
            if (rfvTransInsuranceCompany.IsValid == false)
            {
                ddlTransInsuranceCompany.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTransInsuranceCompany.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTransInsuranceCompany.ControlStyle.CssClass = "";
        }

        //TransInsVehicleNo
        //if (rfvTransInsVehicleNo.Enabled && rfvTransInsVehicleNo.ValidationGroup == strValidationGroup)
        //{
        //    rfvTransInsVehicleNo.Validate();
        //    if (rfvTransInsVehicleNo.IsValid == false)
        //    {
        //        txtTransInsVehicleNo.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtTransInsVehicleNo.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtTransInsVehicleNo.ControlStyle.CssClass = "";
        //}
        //NCDReason
        if (rfvNCDReason.Enabled && rfvNCDReason.ValidationGroup == strValidationGroup)
        {
            rfvNCDReason.Validate();
            if (rfvNCDReason.IsValid == false)
            {
                txtNCDReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNCDReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNCDReason.ControlStyle.CssClass = "";
        }
        //VehicleNo
        if (rfvVehicleNo.Enabled && rfvVehicleNo.ValidationGroup == strValidationGroup)
        {
            rfvVehicleNo.Validate();
            if (rfvVehicleNo.IsValid == false)
            {
                txtVehicleNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVehicleNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVehicleNo.ControlStyle.CssClass = "";
        }
        //EngineType
        if (rfvEngineType.Enabled && rfvEngineType.ValidationGroup == strValidationGroup)
        {
            rfvEngineType.Validate();
            if (rfvEngineType.IsValid == false)
            {
                ddlEngineType.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlEngineType.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlEngineType.ControlStyle.CssClass = "";
        }
        //Purchase Price
        //if (rfvPurchasePrice.Enabled && rfvPurchasePrice.ValidationGroup == strValidationGroup)
        //{
        //    rfvPurchasePrice.Validate();
        //    if (rfvPurchasePrice.IsValid == false)
        //    {
        //        txtPurchasePrice.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtPurchasePrice.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtPurchasePrice.ControlStyle.CssClass = "";
        //}

        if (revPurchasePrice.Enabled && revPurchasePrice.ValidationGroup == strValidationGroup)
        {
            //if (rfvPurchasePrice.IsValid)
            //{
            revPurchasePrice.Validate();
            if (revPurchasePrice.IsValid == false)
            {
                txtPurchasePrice.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPurchasePrice.ControlStyle.CssClass = "";
            }
            //}
        }
        else
        {
            txtPurchasePrice.ControlStyle.CssClass = "";
        }
        //EngineNo
        if (rfvEngineNo.Enabled && rfvEngineNo.ValidationGroup == strValidationGroup)
        {
            rfvEngineNo.Validate();
            if (rfvEngineNo.IsValid == false)
            {
                txtEngineNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEngineNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtEngineNo.ControlStyle.CssClass = "";
        }
        //ChassisNo
        if (rfvChassisNo.Enabled && rfvChassisNo.ValidationGroup == strValidationGroup)
        {
            rfvChassisNo.Validate();
            if (rfvChassisNo.IsValid == false)
            {
                txtChassisNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtChassisNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtChassisNo.ControlStyle.CssClass = "";
        }

        //Vechicle Modification
        if (rfvVechicleModification.Enabled && rfvVechicleModification.ValidationGroup == strValidationGroup)
        {
            rfvVechicleModification.Validate();
            if (rfvVechicleModification.IsValid == false)
            {
                lblYesVechicleModification.ControlStyle.CssClass = "validationError";
                lblNoVechicleModification.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesVechicleModification.ControlStyle.CssClass = "";
                lblNoVechicleModification.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesVechicleModification.ControlStyle.CssClass = "";
            lblNoVechicleModification.ControlStyle.CssClass = "";
        }
        //Vechicle Modification Reason
        if (rfvVMReason.Enabled && rfvVMReason.ValidationGroup == strValidationGroup)
        {
            rfvVMReason.Validate();
            if (rfvVMReason.IsValid == false)
            {
                txtVMReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVMReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVMReason.ControlStyle.CssClass = "";
        }
        //Hire Purchase
        if (rfvHirePurchase.Enabled && rfvHirePurchase.ValidationGroup == strValidationGroup)
        {
            rfvHirePurchase.Validate();
            if (rfvHirePurchase.IsValid == false)
            {
                lblYesHirePurchase.ControlStyle.CssClass = "validationError";
                lblNoHirePurchase.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesHirePurchase.ControlStyle.CssClass = "";
                lblNoHirePurchase.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesHirePurchase.ControlStyle.CssClass = "";
            lblNoHirePurchase.ControlStyle.CssClass = "";
        }
        //HirePurchaseCompany
        if (rfvHirePurchaseCompany.Enabled && rfvHirePurchaseCompany.ValidationGroup == strValidationGroup)
        {
            rfvHirePurchaseCompany.Validate();
            if (rfvHirePurchaseCompany.IsValid == false)
            {
                ddlHirePurchaseCompany.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlHirePurchaseCompany.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlHirePurchaseCompany.ControlStyle.CssClass = "";
        }
        //Purpose of Use
        //if (rfvPurposeofuse.Enabled && rfvPurposeofuse.ValidationGroup == strValidationGroup)
        //{
        //    rfvPurposeofuse.Validate();
        //    if (rfvPurposeofuse.IsValid == false)
        //    {
        //        lblSocial.ControlStyle.CssClass = "validationError";
        //        lblOthers.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        lblSocial.ControlStyle.CssClass = "";
        //        lblOthers.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    lblSocial.ControlStyle.CssClass = "";
        //    lblOthers.ControlStyle.CssClass = "";
        //}

        ////Other Reason
        //if (rfvOtherReason.Enabled && rfvOtherReason.ValidationGroup == strValidationGroup)
        //{
        //    rfvOtherReason.Validate();
        //    if (rfvOtherReason.IsValid == false)
        //    {
        //        txtOtherReason.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtOtherReason.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtOtherReason.ControlStyle.CssClass = "";
        //}

        #endregion

        #region Payment Mode

        ////Payment Mode
        //if (rfvPaymentMode.Enabled && rfvPaymentMode.ValidationGroup == strValidationGroup)
        //{
        //    rfvPaymentMode.Validate();
        //    if (rfvPaymentMode.IsValid == false)
        //    {
        //        lblCashorNets.ControlStyle.CssClass = "validationError";
        //        lblCheque.ControlStyle.CssClass = "validationError";
        //        lblCreditCard.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        lblCashorNets.ControlStyle.CssClass = "";
        //        lblCheque.ControlStyle.CssClass = "";
        //        lblCreditCard.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    lblCashorNets.ControlStyle.CssClass = "";
        //    lblCheque.ControlStyle.CssClass = "";
        //    lblCreditCard.ControlStyle.CssClass = "";
        //}

        ////Bank Name
        //if (rfvBank.Enabled && rfvBank.ValidationGroup == strValidationGroup)
        //{
        //    rfvBank.Validate();
        //    if (rfvBank.IsValid == false)
        //    {
        //        txtBank.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtBank.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtBank.ControlStyle.CssClass = "";
        //}
        ////Cheque No
        //if (rfvChequeNo.Enabled && rfvChequeNo.ValidationGroup == strValidationGroup)
        //{
        //    rfvChequeNo.Validate();
        //    if (rfvChequeNo.IsValid == false)
        //    {
        //        txtChequeNo.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtChequeNo.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtChequeNo.ControlStyle.CssClass = "";
        //}

        //if (revChequeNo.Enabled && revChequeNo.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvChequeNo.IsValid)
        //    {
        //        revChequeNo.Validate();
        //        if (revChequeNo.IsValid == false)
        //        {
        //            txtChequeNo.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtChequeNo.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtChequeNo.ControlStyle.CssClass = "";
        //}
        //Name of the Card
        if (rfvNameoftheCard.Enabled && rfvNameoftheCard.ValidationGroup == strValidationGroup)
        {
            rfvNameoftheCard.Validate();
            if (rfvNameoftheCard.IsValid == false)
            {
                txtNameoftheCard.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNameoftheCard.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNameoftheCard.ControlStyle.CssClass = "";
        }
        //Issuing Bank
        if (rfvIssuingBank.Enabled && rfvIssuingBank.ValidationGroup == strValidationGroup)
        {
            rfvIssuingBank.Validate();
            if (rfvIssuingBank.IsValid == false)
            {
                txtIssuingBank.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtIssuingBank.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtIssuingBank.ControlStyle.CssClass = "";
        }
        //Card 1
        if (rfvCardNo1.Enabled && rfvCardNo1.ValidationGroup == strValidationGroup)
        {
            rfvCardNo1.Validate();
            if (rfvCardNo1.IsValid == false)
            {
                txtCardNo1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo1.ControlStyle.CssClass = "";
        }

        if (revCardNo1.Enabled && revCardNo1.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo1.IsValid)
            {
                revCardNo1.Validate();
                if (revCardNo1.IsValid == false)
                {
                    txtCardNo1.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo1.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo1.ControlStyle.CssClass = "";
        }
        //Card 2
        if (rfvCardNo2.Enabled && rfvCardNo2.ValidationGroup == strValidationGroup)
        {
            rfvCardNo2.Validate();
            if (rfvCardNo2.IsValid == false)
            {
                txtCardNo2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo2.ControlStyle.CssClass = "";
        }

        if (revCardNo2.Enabled && revCardNo2.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo2.IsValid)
            {
                revCardNo2.Validate();
                if (revCardNo2.IsValid == false)
                {
                    txtCardNo2.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo2.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo2.ControlStyle.CssClass = "";
        }
        //Card 3
        if (rfvCardNo3.Enabled && rfvCardNo3.ValidationGroup == strValidationGroup)
        {
            rfvCardNo3.Validate();
            if (rfvCardNo3.IsValid == false)
            {
                txtCardNo3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo3.ControlStyle.CssClass = "";
        }

        if (revCardNo3.Enabled && revCardNo3.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo3.IsValid)
            {
                revCardNo3.Validate();
                if (revCardNo3.IsValid == false)
                {
                    txtCardNo3.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo3.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo3.ControlStyle.CssClass = "";
        }
        //Card 4
        if (rfvCardNo4.Enabled && rfvCardNo4.ValidationGroup == strValidationGroup)
        {
            rfvCardNo4.Validate();
            if (rfvCardNo4.IsValid == false)
            {
                txtCardNo4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo4.ControlStyle.CssClass = "";
        }

        if (revCardNo4.Enabled && revCardNo4.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo4.IsValid)
            {
                revCardNo4.Validate();
                if (revCardNo4.IsValid == false)
                {
                    txtCardNo4.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo4.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo4.ControlStyle.CssClass = "";
        }
        //Card Expiry Month
        if (rfvCardExpiryMonth.Enabled && rfvCardExpiryMonth.ValidationGroup == strValidationGroup)
        {
            rfvCardExpiryMonth.Validate();
            if (rfvCardExpiryMonth.IsValid == false)
            {
                ddlCardExpiryMonth.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCardExpiryMonth.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCardExpiryMonth.ControlStyle.CssClass = "";
        }

        //if (revCardExpiryMonth.Enabled && revCardExpiryMonth.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvCardExpiryMonth.IsValid)
        //    {
        //        revCardExpiryMonth.Validate();
        //        if (revCardExpiryMonth.IsValid == false)
        //        {
        //            txtCardExpiryMonth.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtCardExpiryMonth.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtCardExpiryMonth.ControlStyle.CssClass = "";
        //}
        //Card Expiry Year
        if (rfvCardExpiryYear.Enabled && rfvCardExpiryYear.ValidationGroup == strValidationGroup)
        {
            rfvCardExpiryYear.Validate();
            if (rfvCardExpiryYear.IsValid == false)
            {
                ddlCardExpiryYear.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCardExpiryYear.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCardExpiryYear.ControlStyle.CssClass = "";
        }

        //if (revCardExpiryYear.Enabled && revCardExpiryYear.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvCardExpiryYear.IsValid)
        //    {
        //        revCardExpiryYear.Validate();
        //        if (revCardExpiryYear.IsValid == false)
        //        {
        //            txtCardExpiryYear.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtCardExpiryYear.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtCardExpiryYear.ControlStyle.CssClass = "";
        //}
        //CardType
        if (rfvCardType.Enabled && rfvCardType.ValidationGroup == strValidationGroup)
        {
            rfvCardType.Validate();
            if (rfvCardType.IsValid == false)
            {
                lblVisa.ControlStyle.CssClass = "validationError";
                lblMasterCard.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblVisa.ControlStyle.CssClass = "";
                lblMasterCard.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblVisa.ControlStyle.CssClass = "";
            lblMasterCard.ControlStyle.CssClass = "";
        }

        #endregion

        #region Drivers
        //Driver 1 **************************************************************
        //Salutation
        ddlDriverSalutation1.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName1.Enabled && rfvDriverSurName1.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName1.Validate();
            if (rfvDriverSurName1.IsValid == false)
            {
                txtDriverSurName1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName1.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender1.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender1.Enabled && csvDriverSalGender1.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation1.IsValidRequirement() && ddlDriverGender1.IsValidRequirement())
            {
                csvDriverSalGender1.Validate();
                if (csvDriverSalGender1.IsValid == false)
                {
                    ddlDriverSalutation1.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation1.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation1.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType1.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber1.ChangeValidationEffectServerSide(strValidationGroup);


        if (rfvYearofObtainedDriver1.Enabled && rfvYearofObtainedDriver1.ValidationGroup == strValidationGroup)
        {
            rfvYearofObtainedDriver1.Validate();
            if (rfvYearofObtainedDriver1.IsValid == false)
            {
                ddlYearofObtainedDriver1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofObtainedDriver1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofObtainedDriver1.ControlStyle.CssClass = "";
        }

        ddlDriverRelationship1.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvRevoked1.Enabled && rfvRevoked1.ValidationGroup == strValidationGroup)
        {
            rfvRevoked1.Validate();
            if (rfvRevoked1.IsValid == false)
            {
                lblYesRevoked1.ControlStyle.CssClass = "validationError";
                lblNoRevoked1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesRevoked1.ControlStyle.CssClass = "";
                lblNoRevoked1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesRevoked1.ControlStyle.CssClass = "";
            lblNoRevoked1.ControlStyle.CssClass = "";
        }

        if (rfvYearofRevokedDriver1.Enabled && rfvYearofRevokedDriver1.ValidationGroup == strValidationGroup)
        {
            rfvYearofRevokedDriver1.Validate();
            if (rfvYearofRevokedDriver1.IsValid == false)
            {
                ddlYearofRevokedDriver1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofRevokedDriver1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofRevokedDriver1.ControlStyle.CssClass = "";
        }

        if (rfvLicRevokReason1.Enabled && rfvLicRevokReason1.ValidationGroup == strValidationGroup)
        {
            rfvLicRevokReason1.Validate();
            if (rfvLicRevokReason1.IsValid == false)
            {
                txtLicRevokReason1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtLicRevokReason1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtLicRevokReason1.ControlStyle.CssClass = "";
        }

        if (rfvDriverClaim1.Enabled && rfvDriverClaim1.ValidationGroup == strValidationGroup)
        {
            rfvDriverClaim1.Validate();
            if (rfvDriverClaim1.IsValid == false)
            {
                lblYesDriverClaim1.ControlStyle.CssClass = "validationError";
                lblNoDriverClaim1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDriverClaim1.ControlStyle.CssClass = "";
                lblNoDriverClaim1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDriverClaim1.ControlStyle.CssClass = "";
            lblNoDriverClaim1.ControlStyle.CssClass = "";
        }

        ddlDateofAccidentDriver1.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvNatureofAccidentDriver1.Enabled && rfvNatureofAccidentDriver1.ValidationGroup == strValidationGroup)
        {
            rfvNatureofAccidentDriver1.Validate();
            if (rfvNatureofAccidentDriver1.IsValid == false)
            {
                txtNatureofAccidentDriver1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNatureofAccidentDriver1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNatureofAccidentDriver1.ControlStyle.CssClass = "";
        }

        if (rfvClaimAmountDriver1.Enabled && rfvClaimAmountDriver1.ValidationGroup == strValidationGroup)
        {
            rfvClaimAmountDriver1.Validate();
            if (rfvClaimAmountDriver1.IsValid == false)
            {
                txtClaimAmountDriver1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimAmountDriver1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimAmountDriver1.ControlStyle.CssClass = "";
        }

        if (revClaimAmountDriver1.Enabled && revClaimAmountDriver1.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimAmountDriver1.IsValid)
            {
                revClaimAmountDriver1.Validate();
                if (revClaimAmountDriver1.IsValid == false)
                {
                    txtClaimAmountDriver1.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimAmountDriver1.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimAmountDriver1.ControlStyle.CssClass = "";
        }

        if (rfvTyeofClaimDriver1.Enabled && rfvTyeofClaimDriver1.ValidationGroup == strValidationGroup)
        {
            rfvTyeofClaimDriver1.Validate();
            if (rfvTyeofClaimDriver1.IsValid == false)
            {
                ddlTyeofClaimDriver1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTyeofClaimDriver1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTyeofClaimDriver1.ControlStyle.CssClass = "";
        }

        //Driver 2 **************************************************************
        //Salutation
        ddlDriverSalutation2.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName2.Enabled && rfvDriverSurName2.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName2.Validate();
            if (rfvDriverSurName2.IsValid == false)
            {
                txtDriverSurName2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName2.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender2.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender2.Enabled && csvDriverSalGender2.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation2.IsValidRequirement() && ddlDriverGender2.IsValidRequirement())
            {
                csvDriverSalGender1.Validate();
                if (csvDriverSalGender2.IsValid == false)
                {
                    ddlDriverSalutation2.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation2.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation2.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType2.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber2.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvYearofObtainedDriver2.Enabled && rfvYearofObtainedDriver2.ValidationGroup == strValidationGroup)
        {
            rfvYearofObtainedDriver2.Validate();
            if (rfvYearofObtainedDriver2.IsValid == false)
            {
                ddlYearofObtainedDriver2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofObtainedDriver2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofObtainedDriver2.ControlStyle.CssClass = "";
        }

        ddlDriverRelationship2.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvRevoked2.Enabled && rfvRevoked2.ValidationGroup == strValidationGroup)
        {
            rfvRevoked2.Validate();
            if (rfvRevoked2.IsValid == false)
            {
                lblYesRevoked2.ControlStyle.CssClass = "validationError";
                lblNoRevoked2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesRevoked2.ControlStyle.CssClass = "";
                lblNoRevoked2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesRevoked2.ControlStyle.CssClass = "";
            lblNoRevoked2.ControlStyle.CssClass = "";
        }

        if (rfvYearofRevokedDriver2.Enabled && rfvYearofRevokedDriver2.ValidationGroup == strValidationGroup)
        {
            rfvYearofRevokedDriver2.Validate();
            if (rfvYearofRevokedDriver2.IsValid == false)
            {
                ddlYearofRevokedDriver2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofRevokedDriver2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofRevokedDriver2.ControlStyle.CssClass = "";
        }

        if (rfvLicRevokReason2.Enabled && rfvLicRevokReason2.ValidationGroup == strValidationGroup)
        {
            rfvLicRevokReason2.Validate();
            if (rfvLicRevokReason2.IsValid == false)
            {
                txtLicRevokReason2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtLicRevokReason2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtLicRevokReason2.ControlStyle.CssClass = "";
        }

        if (rfvDriverClaim2.Enabled && rfvDriverClaim2.ValidationGroup == strValidationGroup)
        {
            rfvDriverClaim2.Validate();
            if (rfvDriverClaim2.IsValid == false)
            {
                lblYesDriverClaim2.ControlStyle.CssClass = "validationError";
                lblNoDriverClaim2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDriverClaim2.ControlStyle.CssClass = "";
                lblNoDriverClaim2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDriverClaim2.ControlStyle.CssClass = "";
            lblNoDriverClaim2.ControlStyle.CssClass = "";
        }

        ddlDateofAccidentDriver2.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvNatureofAccidentDriver2.Enabled && rfvNatureofAccidentDriver2.ValidationGroup == strValidationGroup)
        {
            rfvNatureofAccidentDriver2.Validate();
            if (rfvNatureofAccidentDriver2.IsValid == false)
            {
                txtNatureofAccidentDriver2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNatureofAccidentDriver2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNatureofAccidentDriver2.ControlStyle.CssClass = "";
        }

        if (rfvClaimAmountDriver2.Enabled && rfvClaimAmountDriver2.ValidationGroup == strValidationGroup)
        {
            rfvClaimAmountDriver2.Validate();
            if (rfvClaimAmountDriver2.IsValid == false)
            {
                txtClaimAmountDriver2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimAmountDriver2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimAmountDriver2.ControlStyle.CssClass = "";
        }

        if (revClaimAmountDriver2.Enabled && revClaimAmountDriver2.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimAmountDriver2.IsValid)
            {
                revClaimAmountDriver2.Validate();
                if (revClaimAmountDriver2.IsValid == false)
                {
                    txtClaimAmountDriver2.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimAmountDriver2.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimAmountDriver2.ControlStyle.CssClass = "";
        }

        if (rfvTyeofClaimDriver2.Enabled && rfvTyeofClaimDriver2.ValidationGroup == strValidationGroup)
        {
            rfvTyeofClaimDriver2.Validate();
            if (rfvTyeofClaimDriver2.IsValid == false)
            {
                ddlTyeofClaimDriver2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTyeofClaimDriver2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTyeofClaimDriver2.ControlStyle.CssClass = "";
        }

        //Driver 3 **************************************************************
        //Salutation
        ddlDriverSalutation3.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName3.Enabled && rfvDriverSurName3.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName3.Validate();
            if (rfvDriverSurName3.IsValid == false)
            {
                txtDriverSurName3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName3.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender3.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender3.Enabled && csvDriverSalGender3.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation3.IsValidRequirement() && ddlDriverGender3.IsValidRequirement())
            {
                csvDriverSalGender3.Validate();
                if (csvDriverSalGender3.IsValid == false)
                {
                    ddlDriverSalutation3.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation3.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation3.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType3.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber3.ChangeValidationEffectServerSide(strValidationGroup);


        if (rfvYearofObtainedDriver3.Enabled && rfvYearofObtainedDriver3.ValidationGroup == strValidationGroup)
        {
            rfvYearofObtainedDriver3.Validate();
            if (rfvYearofObtainedDriver3.IsValid == false)
            {
                ddlYearofObtainedDriver3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofObtainedDriver3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofObtainedDriver3.ControlStyle.CssClass = "";
        }

        ddlDriverRelationship3.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvRevoked3.Enabled && rfvRevoked3.ValidationGroup == strValidationGroup)
        {
            rfvRevoked3.Validate();
            if (rfvRevoked3.IsValid == false)
            {
                lblYesRevoked3.ControlStyle.CssClass = "validationError";
                lblNoRevoked3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesRevoked3.ControlStyle.CssClass = "";
                lblNoRevoked3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesRevoked3.ControlStyle.CssClass = "";
            lblNoRevoked3.ControlStyle.CssClass = "";
        }

        if (rfvYearofRevokedDriver3.Enabled && rfvYearofRevokedDriver3.ValidationGroup == strValidationGroup)
        {
            rfvYearofRevokedDriver3.Validate();
            if (rfvYearofRevokedDriver3.IsValid == false)
            {
                ddlYearofRevokedDriver3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofRevokedDriver3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofRevokedDriver3.ControlStyle.CssClass = "";
        }

        if (rfvLicRevokReason3.Enabled && rfvLicRevokReason3.ValidationGroup == strValidationGroup)
        {
            rfvLicRevokReason3.Validate();
            if (rfvLicRevokReason3.IsValid == false)
            {
                txtLicRevokReason3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtLicRevokReason3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtLicRevokReason3.ControlStyle.CssClass = "";
        }

        if (rfvDriverClaim3.Enabled && rfvDriverClaim3.ValidationGroup == strValidationGroup)
        {
            rfvDriverClaim3.Validate();
            if (rfvDriverClaim3.IsValid == false)
            {
                lblYesDriverClaim3.ControlStyle.CssClass = "validationError";
                lblNoDriverClaim3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDriverClaim3.ControlStyle.CssClass = "";
                lblNoDriverClaim3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDriverClaim3.ControlStyle.CssClass = "";
            lblNoDriverClaim3.ControlStyle.CssClass = "";
        }

        ddlDateofAccidentDriver3.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvNatureofAccidentDriver3.Enabled && rfvNatureofAccidentDriver3.ValidationGroup == strValidationGroup)
        {
            rfvNatureofAccidentDriver3.Validate();
            if (rfvNatureofAccidentDriver3.IsValid == false)
            {
                txtNatureofAccidentDriver3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNatureofAccidentDriver3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNatureofAccidentDriver3.ControlStyle.CssClass = "";
        }

        if (rfvClaimAmountDriver3.Enabled && rfvClaimAmountDriver3.ValidationGroup == strValidationGroup)
        {
            rfvClaimAmountDriver3.Validate();
            if (rfvClaimAmountDriver3.IsValid == false)
            {
                txtClaimAmountDriver3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimAmountDriver3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimAmountDriver3.ControlStyle.CssClass = "";
        }

        if (revClaimAmountDriver3.Enabled && revClaimAmountDriver3.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimAmountDriver3.IsValid)
            {
                revClaimAmountDriver3.Validate();
                if (revClaimAmountDriver3.IsValid == false)
                {
                    txtClaimAmountDriver3.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimAmountDriver3.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimAmountDriver3.ControlStyle.CssClass = "";
        }

        if (rfvTyeofClaimDriver3.Enabled && rfvTyeofClaimDriver3.ValidationGroup == strValidationGroup)
        {
            rfvTyeofClaimDriver3.Validate();
            if (rfvTyeofClaimDriver3.IsValid == false)
            {
                ddlTyeofClaimDriver3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTyeofClaimDriver3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTyeofClaimDriver3.ControlStyle.CssClass = "";
        }

        //Driver 4 **************************************************************
        //Salutation
        ddlDriverSalutation4.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName4.Enabled && rfvDriverSurName4.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName4.Validate();
            if (rfvDriverSurName4.IsValid == false)
            {
                txtDriverSurName4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName4.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender4.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender4.Enabled && csvDriverSalGender4.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation4.IsValidRequirement() && ddlDriverGender4.IsValidRequirement())
            {
                csvDriverSalGender4.Validate();
                if (csvDriverSalGender4.IsValid == false)
                {
                    ddlDriverSalutation4.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation4.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation4.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType4.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber4.ChangeValidationEffectServerSide(strValidationGroup);


        if (rfvYearofObtainedDriver4.Enabled && rfvYearofObtainedDriver4.ValidationGroup == strValidationGroup)
        {
            rfvYearofObtainedDriver4.Validate();
            if (rfvYearofObtainedDriver4.IsValid == false)
            {
                ddlYearofObtainedDriver4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofObtainedDriver4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofObtainedDriver4.ControlStyle.CssClass = "";
        }

        ddlDriverRelationship4.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvRevoked4.Enabled && rfvRevoked4.ValidationGroup == strValidationGroup)
        {
            rfvRevoked4.Validate();
            if (rfvRevoked4.IsValid == false)
            {
                lblYesRevoked4.ControlStyle.CssClass = "validationError";
                lblNoRevoked4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesRevoked4.ControlStyle.CssClass = "";
                lblNoRevoked4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesRevoked4.ControlStyle.CssClass = "";
            lblNoRevoked4.ControlStyle.CssClass = "";
        }

        if (rfvYearofRevokedDriver4.Enabled && rfvYearofRevokedDriver4.ValidationGroup == strValidationGroup)
        {
            rfvYearofRevokedDriver4.Validate();
            if (rfvYearofRevokedDriver4.IsValid == false)
            {
                ddlYearofRevokedDriver4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofRevokedDriver4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofRevokedDriver4.ControlStyle.CssClass = "";
        }

        if (rfvLicRevokReason4.Enabled && rfvLicRevokReason4.ValidationGroup == strValidationGroup)
        {
            rfvLicRevokReason4.Validate();
            if (rfvLicRevokReason4.IsValid == false)
            {
                txtLicRevokReason4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtLicRevokReason4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtLicRevokReason4.ControlStyle.CssClass = "";
        }

        if (rfvDriverClaim4.Enabled && rfvDriverClaim4.ValidationGroup == strValidationGroup)
        {
            rfvDriverClaim4.Validate();
            if (rfvDriverClaim4.IsValid == false)
            {
                lblYesDriverClaim4.ControlStyle.CssClass = "validationError";
                lblNoDriverClaim4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDriverClaim4.ControlStyle.CssClass = "";
                lblNoDriverClaim4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDriverClaim4.ControlStyle.CssClass = "";
            lblNoDriverClaim4.ControlStyle.CssClass = "";
        }

        ddlDateofAccidentDriver4.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvNatureofAccidentDriver4.Enabled && rfvNatureofAccidentDriver4.ValidationGroup == strValidationGroup)
        {
            rfvNatureofAccidentDriver4.Validate();
            if (rfvNatureofAccidentDriver4.IsValid == false)
            {
                txtNatureofAccidentDriver4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNatureofAccidentDriver4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNatureofAccidentDriver4.ControlStyle.CssClass = "";
        }

        if (rfvClaimAmountDriver4.Enabled && rfvClaimAmountDriver4.ValidationGroup == strValidationGroup)
        {
            rfvClaimAmountDriver4.Validate();
            if (rfvClaimAmountDriver4.IsValid == false)
            {
                txtClaimAmountDriver4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimAmountDriver4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimAmountDriver4.ControlStyle.CssClass = "";
        }

        if (revClaimAmountDriver4.Enabled && revClaimAmountDriver4.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimAmountDriver4.IsValid)
            {
                revClaimAmountDriver4.Validate();
                if (revClaimAmountDriver4.IsValid == false)
                {
                    txtClaimAmountDriver4.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimAmountDriver4.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimAmountDriver4.ControlStyle.CssClass = "";
        }

        if (rfvTyeofClaimDriver4.Enabled && rfvTyeofClaimDriver4.ValidationGroup == strValidationGroup)
        {
            rfvTyeofClaimDriver4.Validate();
            if (rfvTyeofClaimDriver4.IsValid == false)
            {
                ddlTyeofClaimDriver4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTyeofClaimDriver4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTyeofClaimDriver4.ControlStyle.CssClass = "";
        }

        //Driver 5 **************************************************************
        //Salutation
        ddlDriverSalutation5.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName5.Enabled && rfvDriverSurName5.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName5.Validate();
            if (rfvDriverSurName5.IsValid == false)
            {
                txtDriverSurName5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName5.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender5.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender5.Enabled && csvDriverSalGender5.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation5.IsValidRequirement() && ddlDriverGender5.IsValidRequirement())
            {
                csvDriverSalGender5.Validate();
                if (csvDriverSalGender5.IsValid == false)
                {
                    ddlDriverSalutation5.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation5.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation5.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType5.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber5.ChangeValidationEffectServerSide(strValidationGroup);


        if (rfvYearofObtainedDriver5.Enabled && rfvYearofObtainedDriver5.ValidationGroup == strValidationGroup)
        {
            rfvYearofObtainedDriver5.Validate();
            if (rfvYearofObtainedDriver5.IsValid == false)
            {
                ddlYearofObtainedDriver5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofObtainedDriver5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofObtainedDriver5.ControlStyle.CssClass = "";
        }

        ddlDriverRelationship5.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvRevoked5.Enabled && rfvRevoked5.ValidationGroup == strValidationGroup)
        {
            rfvRevoked5.Validate();
            if (rfvRevoked5.IsValid == false)
            {
                lblYesRevoked5.ControlStyle.CssClass = "validationError";
                lblNoRevoked5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesRevoked5.ControlStyle.CssClass = "";
                lblNoRevoked5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesRevoked5.ControlStyle.CssClass = "";
            lblNoRevoked5.ControlStyle.CssClass = "";
        }

        if (rfvYearofRevokedDriver5.Enabled && rfvYearofRevokedDriver5.ValidationGroup == strValidationGroup)
        {
            rfvYearofRevokedDriver5.Validate();
            if (rfvYearofRevokedDriver5.IsValid == false)
            {
                ddlYearofRevokedDriver5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearofRevokedDriver5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearofRevokedDriver5.ControlStyle.CssClass = "";
        }

        if (rfvLicRevokReason5.Enabled && rfvLicRevokReason5.ValidationGroup == strValidationGroup)
        {
            rfvLicRevokReason5.Validate();
            if (rfvLicRevokReason5.IsValid == false)
            {
                txtLicRevokReason5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtLicRevokReason5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtLicRevokReason5.ControlStyle.CssClass = "";
        }

        if (rfvDriverClaim5.Enabled && rfvDriverClaim5.ValidationGroup == strValidationGroup)
        {
            rfvDriverClaim5.Validate();
            if (rfvDriverClaim5.IsValid == false)
            {
                lblYesDriverClaim5.ControlStyle.CssClass = "validationError";
                lblNoDriverClaim5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDriverClaim5.ControlStyle.CssClass = "";
                lblNoDriverClaim5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDriverClaim5.ControlStyle.CssClass = "";
            lblNoDriverClaim5.ControlStyle.CssClass = "";
        }

        ddlDateofAccidentDriver5.ChangeValidationEffectServerSide(strValidationGroup);

        if (rfvNatureofAccidentDriver5.Enabled && rfvNatureofAccidentDriver5.ValidationGroup == strValidationGroup)
        {
            rfvNatureofAccidentDriver5.Validate();
            if (rfvNatureofAccidentDriver5.IsValid == false)
            {
                txtNatureofAccidentDriver5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNatureofAccidentDriver5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNatureofAccidentDriver5.ControlStyle.CssClass = "";
        }

        if (rfvClaimAmountDriver5.Enabled && rfvClaimAmountDriver5.ValidationGroup == strValidationGroup)
        {
            rfvClaimAmountDriver5.Validate();
            if (rfvClaimAmountDriver5.IsValid == false)
            {
                txtClaimAmountDriver5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimAmountDriver5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimAmountDriver5.ControlStyle.CssClass = "";
        }

        if (revClaimAmountDriver5.Enabled && revClaimAmountDriver5.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimAmountDriver5.IsValid)
            {
                revClaimAmountDriver5.Validate();
                if (revClaimAmountDriver5.IsValid == false)
                {
                    txtClaimAmountDriver5.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimAmountDriver5.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimAmountDriver5.ControlStyle.CssClass = "";
        }

        if (rfvTyeofClaimDriver5.Enabled && rfvTyeofClaimDriver5.ValidationGroup == strValidationGroup)
        {
            rfvTyeofClaimDriver5.Validate();
            if (rfvTyeofClaimDriver5.IsValid == false)
            {
                ddlTyeofClaimDriver5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlTyeofClaimDriver5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlTyeofClaimDriver5.ControlStyle.CssClass = "";
        }

        #endregion

    }

    protected void CheckDriverSalGenderValid1(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation1.GetSalutation();
        string _gender = ddlDriverGender1.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid2(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation2.GetSalutation();
        string _gender = ddlDriverGender2.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid3(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation3.GetSalutation();
        string _gender = ddlDriverGender3.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid4(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation4.GetSalutation();
        string _gender = ddlDriverGender4.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid5(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation5.GetSalutation();
        string _gender = ddlDriverGender5.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    private void EnableClaim()
    {
        if (txtAnyClaim.Text.Trim() == "Yes")
        {
            pnlClaimDetails.Visible = true;
            ddlDateofAccident.IsEnableValidation(true);
            rfvNatureofAccident.Enabled = true;
            rfvTyeofClaim.Enabled = true;
        }
        else
        {
            pnlClaimDetails.Visible = false;
            ddlDateofAccident.IsEnableValidation(false);
            rfvNatureofAccident.Enabled = false;
            rfvTyeofClaim.Enabled = false;
        }
    }

    private void EnableDriverPanels()
    {
        if (txtDriverCount.Text.Trim() == "0")
        {
            pnlDriverDetails.Visible = false;
            pnlDriver1.Visible = false;
            pnlDriver2.Visible = false;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(false);
            ValidateDriver2(false);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "1")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = false;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(false);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "2")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "3")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "4")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = true;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(true);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "5")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = true;
            pnlDriver5.Visible = true;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(true);
            ValidateDriver5(true);
        }
    }

    private void ValidateDriver1(bool OnOff)
    {
        rfvDriverSurName1.Enabled = OnOff;
        ddlDriverSalutation1.IsEnableValidation(OnOff);
        ddlDriverGender1.IsEnableValidation(OnOff);
        ddlDriverIdType1.IsEnableValidation(OnOff);
        ddlDriverIdNumber1.IsEnableValidation(OnOff);
        csvDriverSalGender1.Enabled = OnOff;

        //rfvRevoked1.Enabled = OnOff;
        //if (rfvRevoked1.Enabled == true)
        //{
        //    rfvYearofRevokedDriver1.Enabled = true;
        //    rfvLicRevokReason1.Enabled = true;
        //    //if (rdoYesRevoked1.Checked)
        //    //{
        //    //    rfvYearofRevokedDriver1.Enabled = true;
        //    //    rfvLicRevokReason1.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    rfvYearofRevokedDriver1.Enabled = false;
        //    //    rfvLicRevokReason1.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    rfvYearofRevokedDriver1.Enabled = false;
        //    rfvLicRevokReason1.Enabled = false;
        //}
        //rfvDriverClaim1.Enabled = OnOff;
        //if (rfvDriverClaim1.Enabled == true)
        //{
        //    ddlDateofAccidentDriver1.IsEnableValidation(true);
        //    rfvNatureofAccidentDriver1.Enabled = true;
        //    rfvClaimAmountDriver1.Enabled = true;
        //    revClaimAmountDriver1.Enabled = true;
        //    rfvTyeofClaimDriver1.Enabled = true;
        //    //if (rdoYesDriverClaim1.Checked)
        //    //{
        //    //    ddlDateofAccidentDriver1.IsEnableValidation(true);
        //    //    rfvNatureofAccidentDriver1.Enabled = true;
        //    //    rfvClaimAmountDriver1.Enabled = true;
        //    //    revClaimAmountDriver1.Enabled = true;
        //    //    rfvTyeofClaimDriver1.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    ddlDateofAccidentDriver1.IsEnableValidation(false);
        //    //    rfvNatureofAccidentDriver1.Enabled = false;
        //    //    rfvClaimAmountDriver1.Enabled = false;
        //    //    revClaimAmountDriver1.Enabled = false;
        //    //    rfvTyeofClaimDriver1.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    ddlDateofAccidentDriver1.IsEnableValidation(false);
        //    rfvNatureofAccidentDriver1.Enabled = false;
        //    rfvClaimAmountDriver1.Enabled = false;
        //    revClaimAmountDriver1.Enabled = false;
        //    rfvTyeofClaimDriver1.Enabled = false;
        //}
    }

    private void ValidateDriver2(bool OnOff)
    {
        rfvDriverSurName2.Enabled = OnOff;
        ddlDriverSalutation2.IsEnableValidation(OnOff);
        ddlDriverGender2.IsEnableValidation(OnOff);
        ddlDriverIdType2.IsEnableValidation(OnOff);
        ddlDriverIdNumber2.IsEnableValidation(OnOff);
        csvDriverSalGender2.Enabled = OnOff;

        //rfvRevoked2.Enabled = OnOff;
        //if (rfvRevoked2.Enabled == true)
        //{
        //    rfvYearofRevokedDriver2.Enabled = true;
        //    rfvLicRevokReason2.Enabled = true;
        //    //if (rdoYesRevoked2.Checked)
        //    //{
        //    //    rfvYearofRevokedDriver2.Enabled = true;
        //    //    rfvLicRevokReason2.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    rfvYearofRevokedDriver2.Enabled = false;
        //    //    rfvLicRevokReason2.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    rfvYearofRevokedDriver2.Enabled = false;
        //    rfvLicRevokReason2.Enabled = false;
        //}
        //rfvDriverClaim2.Enabled = OnOff;
        //if (rfvDriverClaim2.Enabled == true)
        //{
        //    ddlDateofAccidentDriver2.IsEnableValidation(true);
        //    rfvNatureofAccidentDriver2.Enabled = true;
        //    rfvClaimAmountDriver2.Enabled = true;
        //    revClaimAmountDriver2.Enabled = true;
        //    rfvTyeofClaimDriver2.Enabled = true;
        //    //if (rdoYesDriverClaim2.Checked)
        //    //{
        //    //    ddlDateofAccidentDriver2.IsEnableValidation(true);
        //    //    rfvNatureofAccidentDriver2.Enabled = true;
        //    //    rfvClaimAmountDriver2.Enabled = true;
        //    //    revClaimAmountDriver2.Enabled = true;
        //    //    rfvTyeofClaimDriver2.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    ddlDateofAccidentDriver2.IsEnableValidation(false);
        //    //    rfvNatureofAccidentDriver2.Enabled = false;
        //    //    rfvClaimAmountDriver2.Enabled = false;
        //    //    revClaimAmountDriver2.Enabled = false;
        //    //    rfvTyeofClaimDriver2.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    ddlDateofAccidentDriver2.IsEnableValidation(false);
        //    rfvNatureofAccidentDriver2.Enabled = false;
        //    rfvClaimAmountDriver2.Enabled = false;
        //    revClaimAmountDriver2.Enabled = false;
        //    rfvTyeofClaimDriver2.Enabled = false;
        //}
    }

    private void ValidateDriver3(bool OnOff)
    {
        rfvDriverSurName3.Enabled = OnOff;
        ddlDriverSalutation3.IsEnableValidation(OnOff);
        ddlDriverGender3.IsEnableValidation(OnOff);
        ddlDriverIdType3.IsEnableValidation(OnOff);
        ddlDriverIdNumber3.IsEnableValidation(OnOff);
        csvDriverSalGender3.Enabled = OnOff;

        //rfvRevoked3.Enabled = OnOff;
        //if (rfvRevoked3.Enabled == true)
        //{
        //    rfvYearofRevokedDriver1.Enabled = true;
        //    rfvLicRevokReason1.Enabled = true;
        //    //if (rdoYesRevoked3.Checked)
        //    //{
        //    //    rfvYearofRevokedDriver1.Enabled = true;
        //    //    rfvLicRevokReason1.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    rfvYearofRevokedDriver3.Enabled = false;
        //    //    rfvLicRevokReason3.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    rfvYearofRevokedDriver3.Enabled = false;
        //    rfvLicRevokReason3.Enabled = false;
        //}
        //rfvDriverClaim3.Enabled = OnOff;
        //if (rfvDriverClaim3.Enabled == true)
        //{
        //    ddlDateofAccidentDriver3.IsEnableValidation(true);
        //    rfvNatureofAccidentDriver3.Enabled = true;
        //    rfvClaimAmountDriver3.Enabled = true;
        //    revClaimAmountDriver3.Enabled = true;
        //    rfvTyeofClaimDriver3.Enabled = true;
        //    //if (rdoYesDriverClaim3.Checked)
        //    //{
        //    //    ddlDateofAccidentDriver3.IsEnableValidation(true);
        //    //    rfvNatureofAccidentDriver3.Enabled = true;
        //    //    rfvClaimAmountDriver3.Enabled = true;
        //    //    revClaimAmountDriver3.Enabled = true;
        //    //    rfvTyeofClaimDriver3.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    ddlDateofAccidentDriver3.IsEnableValidation(false);
        //    //    rfvNatureofAccidentDriver3.Enabled = false;
        //    //    rfvClaimAmountDriver3.Enabled = false;
        //    //    revClaimAmountDriver3.Enabled = false;
        //    //    rfvTyeofClaimDriver3.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    ddlDateofAccidentDriver3.IsEnableValidation(false);
        //    rfvNatureofAccidentDriver3.Enabled = false;
        //    rfvClaimAmountDriver3.Enabled = false;
        //    revClaimAmountDriver3.Enabled = false;
        //    rfvTyeofClaimDriver3.Enabled = false;
        //}
    }

    private void ValidateDriver4(bool OnOff)
    {
        rfvDriverSurName4.Enabled = OnOff;
        ddlDriverSalutation4.IsEnableValidation(OnOff);
        ddlDriverGender4.IsEnableValidation(OnOff);
        ddlDriverIdType4.IsEnableValidation(OnOff);
        ddlDriverIdNumber4.IsEnableValidation(OnOff);
        csvDriverSalGender4.Enabled = OnOff;

        //rfvRevoked4.Enabled = OnOff;
        //if (rfvRevoked4.Enabled == true)
        //{
        //    rfvYearofRevokedDriver4.Enabled = true;
        //    rfvLicRevokReason4.Enabled = true;
        //    //if (rdoYesRevoked4.Checked)
        //    //{
        //    //    rfvYearofRevokedDriver4.Enabled = true;
        //    //    rfvLicRevokReason4.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    rfvYearofRevokedDriver4.Enabled = false;
        //    //    rfvLicRevokReason4.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    rfvYearofRevokedDriver4.Enabled = false;
        //    rfvLicRevokReason4.Enabled = false;
        //}
        //rfvDriverClaim4.Enabled = OnOff;
        //if (rfvDriverClaim4.Enabled == true)
        //{
        //    ddlDateofAccidentDriver4.IsEnableValidation(true);
        //    rfvNatureofAccidentDriver4.Enabled = true;
        //    rfvClaimAmountDriver4.Enabled = true;
        //    revClaimAmountDriver4.Enabled = true;
        //    rfvTyeofClaimDriver4.Enabled = true;
        //    //if (rdoYesDriverClaim4.Checked)
        //    //{
        //    //    ddlDateofAccidentDriver4.IsEnableValidation(true);
        //    //    rfvNatureofAccidentDriver4.Enabled = true;
        //    //    rfvClaimAmountDriver4.Enabled = true;
        //    //    revClaimAmountDriver4.Enabled = true;
        //    //    rfvTyeofClaimDriver4.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    ddlDateofAccidentDriver4.IsEnableValidation(false);
        //    //    rfvNatureofAccidentDriver4.Enabled = false;
        //    //    rfvClaimAmountDriver4.Enabled = false;
        //    //    revClaimAmountDriver4.Enabled = false;
        //    //    rfvTyeofClaimDriver4.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    ddlDateofAccidentDriver4.IsEnableValidation(false);
        //    rfvNatureofAccidentDriver4.Enabled = false;
        //    rfvClaimAmountDriver4.Enabled = false;
        //    revClaimAmountDriver4.Enabled = false;
        //    rfvTyeofClaimDriver4.Enabled = false;
        //}
    }

    private void ValidateDriver5(bool OnOff)
    {
        rfvDriverSurName5.Enabled = OnOff;
        ddlDriverSalutation5.IsEnableValidation(OnOff);
        ddlDriverGender5.IsEnableValidation(OnOff);
        ddlDriverIdType5.IsEnableValidation(OnOff);
        ddlDriverIdNumber5.IsEnableValidation(OnOff);
        csvDriverSalGender5.Enabled = OnOff;

        //rfvRevoked5.Enabled = OnOff;
        //if (rfvRevoked5.Enabled == true)
        //{
        //    rfvYearofRevokedDriver5.Enabled = true;
        //    rfvLicRevokReason5.Enabled = true;
        //    //if (rdoYesRevoked5.Checked)
        //    //{
        //    //    rfvYearofRevokedDriver5.Enabled = true;
        //    //    rfvLicRevokReason5.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    rfvYearofRevokedDriver5.Enabled = false;
        //    //    rfvLicRevokReason5.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    rfvYearofRevokedDriver5.Enabled = false;
        //    rfvLicRevokReason5.Enabled = false;
        //}
        //rfvDriverClaim5.Enabled = OnOff;
        //if (rfvDriverClaim5.Enabled == true)
        //{
        //    ddlDateofAccidentDriver5.IsEnableValidation(true);
        //    rfvNatureofAccidentDriver5.Enabled = true;
        //    rfvClaimAmountDriver5.Enabled = true;
        //    revClaimAmountDriver5.Enabled = true;
        //    rfvTyeofClaimDriver5.Enabled = true;
        //    //if (rdoYesDriverClaim5.Checked)
        //    //{
        //    //    ddlDateofAccidentDriver5.IsEnableValidation(true);
        //    //    rfvNatureofAccidentDriver5.Enabled = true;
        //    //    rfvClaimAmountDriver5.Enabled = true;
        //    //    revClaimAmountDriver5.Enabled = true;
        //    //    rfvTyeofClaimDriver5.Enabled = true;
        //    //}
        //    //else
        //    //{
        //    //    ddlDateofAccidentDriver5.IsEnableValidation(false);
        //    //    rfvNatureofAccidentDriver5.Enabled = false;
        //    //    rfvClaimAmountDriver5.Enabled = false;
        //    //    revClaimAmountDriver5.Enabled = false;
        //    //    rfvTyeofClaimDriver5.Enabled = false;
        //    //}
        //}
        //else
        //{
        //    ddlDateofAccidentDriver5.IsEnableValidation(false);
        //    rfvNatureofAccidentDriver5.Enabled = false;
        //    rfvClaimAmountDriver5.Enabled = false;
        //    revClaimAmountDriver5.Enabled = false;
        //    rfvTyeofClaimDriver5.Enabled = false;
        //}
    }

    protected void csvCreditCardValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        bool _status = true;
        if (txtCardNo1.Text.Length > 2)
        {
            string _first = txtCardNo1.Text.Trim().Substring(0, 1);

            if (rdoVisa.Checked)
            {
                if (_first != "4")
                {
                    _status = false;
                }
            }
            else if (rdoMasterCard.Checked)
            {
                if (_first != "5")
                {
                    _status = false;
                }
            }
            if (_status == true)
            {
                txtCreditCardValid.Text = "";
                txtCreditCardValid.Text = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
                string _cardNumer = txtCreditCardValid.Text;
                MySecurity _mysecurity = new MySecurity();
                if (_mysecurity.IsCreditCardValid(_cardNumer))
                {
                    args.IsValid = true;
                }
                else
                {
                    args.IsValid = false;
                }
            }
            else
            {
                args.IsValid = false;
            }
        }
    }

    protected void csvCCExpiredValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtCCExpiredValid.Text = "";
        txtCCExpiredValid.Text = "valid";
        Int32 _Year = Convert.ToInt32(ddlCardExpiryYear.Text);
        Int32 _Month = Convert.ToInt32(ddlCardExpiryMonth.Text);

        MySecurity _mysecurity = new MySecurity();
        if (_mysecurity.IsCreditCardExpiredDateValid(_Year, _Month))
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }

    protected void csvVehicleNoValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtVehicleNoValid.Text = "";
        txtVehicleNoValid.Text = "valid";
        string _VehicleNo = txtVehicleNo.Text.Trim();
        string _FirstLetter = _VehicleNo.Substring(0, 1);
        string _blockVal = CE.Configuration.MyConfigurationManager.GetAppSettingValue("BlockedVehicleChar");
        string[] _BlockedVehicleChar = _blockVal.Split(',');
        args.IsValid = true;
        for (int i = 0; i < _BlockedVehicleChar.Length; i++)
        {
            if (_FirstLetter.ToUpper() == _BlockedVehicleChar[i].ToString())
            {
                args.IsValid = false;
            }
        }
    }

    //public bool ValidExpiredDate(Int32 Year, Int32 Month)
    //{
    //    bool _IsValid = true;
    //    DateTime today = CE.Global.General.GetUTCDateTime();
    //    Int32 mm = today.Month;
    //    Int32 yyyy = today.Year;
    //    string monthValid, yearValid;

    //    if (Year >= yyyy)
    //    {
    //        yearValid = "yes";
    //    }
    //    else
    //    {
    //        yearValid = "no";
    //    }
    //    if (Month >= mm)
    //    {
    //        monthValid = "yes";
    //    }
    //    else
    //    {
    //        monthValid = "no";
    //    }
    //    if ((monthValid == "yes") && (yearValid == "yes"))
    //    {
    //        _IsValid = true;
    //    }
    //    else
    //    {
    //        _IsValid = false;
    //    }
    //    return _IsValid;
    //}

    private bool CheckCarQuoteUpdateStatus()
    {
        bool _retValue = false;
        CarInsuranceCheckDB _carcheck = new CarInsuranceCheckDB();
        Int64 _checkResult = _carcheck.CheckUpdateStatus(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()), Convert.ToInt64(Session[General.CarResultId].ToString()), Convert.ToInt64(Session[General.UserId].ToString()), Convert.ToInt64(Session[General.CarId].ToString()));
        if (_checkResult > 0)
        {
            _retValue = true;
        }
        else
        {
            _retValue = false;
        }

        return _retValue;
    }

    protected void ibtPostCode_Click(object sender, ImageClickEventArgs e)
    {
        GetPostCode();
    }

    private void GetPostCode()
    {
        rfvPostCode.Validate();
        revPostCode.Validate();
        if (rfvPostCode.IsValid && revPostCode.IsValid)
        {
            txtPostCode.ControlStyle.CssClass = "";
            txtAddress.ControlStyle.CssClass = "";
            MyLocation _myLoc = new MyLocation();
            //string _strAddress = _myLoc.GetAddressByPostCode(txtPostCode.Text);
            //if (_strAddress != null && _strAddress != string.Empty)
            //{
            //    if (_strAddress.ToLower().Contains("invalid api"))
            //    {
            //        txtAddress.Text = "Address can't be retrieved. Please type your address detail here.";
            //    }
            //    else
            //    {
            //        txtAddress.Text = _strAddress;
            //    }
            //}
            //else
            //{
            //    txtAddress.Text = "Address is not found.";
            //}

            System.Data.DataSet _ds = _myLoc.GetAddressByPostCodeDataSet(txtPostCode.Text);
            ddlAddressList.Items.Clear();
            string _lstValue;
            string _lstText;
            int _rowCount = 0;

            if (_ds != null)
            {
                if (_ds.Tables.Count > 0)
                {
                    foreach (System.Data.DataTable _dt in _ds.Tables)
                    {
                        if (_dt.Rows.Count > 0 && _dt.Columns.Count >= 2)
                        {
                            foreach (System.Data.DataRow _dr in _dt.Rows)
                            {
                                //lblAddress2.Text += _dr["t"].ToString() + "<br />";
                                //lblAddress2.Text += _dr["a"].ToString() + "<br /><br />";
                                
                                if (_dr["t"] != null && _dr["a"] != null)
                                {
                                    _lstValue = _dr["t"].ToString() + ", " + _dr["a"].ToString();
                                    _lstText = _dr["t"].ToString();
                                    ddlAddressList.Items.Add(new ListItem(_lstText, _lstValue));
                                    if (_rowCount == 0)
                                    {
                                        txtAddress.Text = _lstValue;
                                        //ibtPostCode.Enabled = false;
                                        txtAddress.ReadOnly = true;
                                    }

                                    _rowCount++;
                                }
                            }
                        }
                        else
                        {
                            txtAddress.Text = "Confirm postcode or enter manually.";
                            txtAddress.ReadOnly = false;
                            txtAddress.ControlStyle.CssClass = "validationError";
                        }
                    }
                }
                else
                {
                    txtAddress.Text = "Confirm postcode or enter manually.";
                    txtAddress.ReadOnly = false;
                    txtAddress.ControlStyle.CssClass = "validationError";
                }
            }
            else
            {
                txtAddress.Text = "Please type your address here.";
                txtAddress.ReadOnly = false;
                txtAddress.ControlStyle.CssClass = "validationError";
            }

            if (_rowCount > 1)
            {
                divAddressList.Visible = true;
            }
            else
            {
                divAddressList.Visible = false;

            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "validationError";
            ddlAddressList.Items.Clear();
            divAddressList.Visible = false;
            txtAddress.Text = "Invalid postcode.";
            txtAddress.ControlStyle.CssClass = "validationError";
        }
    }

    //protected void DriverFieldValidate(object source, ServerValidateEventArgs args)
    //{
    //    if (txtDriverValid.Text.ToLower() == "valid")
    //        args.IsValid = true;
    //    else
    //        args.IsValid = false;
    //}

    //private void ShowPolicyDetail(Int64 CarId, Int64 PolicyId, Int64 UserId)
    //{
    //    CarPolicy _carpolicy = new CarPolicy();
    //    CarPolicyDB _carpolicydb = new CarPolicyDB();
    //    _carpolicy = _carpolicydb.GetCarPolicy(CarId, PolicyId, UserId);
    //    if (_carpolicy != null)
    //    {
    //        SetProperty(_carpolicy);
    //    }
    //    _carpolicy = null;
    //    _carpolicydb = null;
    //}

    //private void SetProperty(CarPolicy _CarPolicy)
    //{
    //    if (_CarPolicy.IsAddDriver == true)
    //    {
    //        txtDriverCount.Text = _CarPolicy.NoOfDriver.ToString();
    //    }
    //    else
    //    {
    //        txtDriverCount.Text = "0";
    //    }

    //    if (_CarPolicy.NoOfDriver > 0 && txtDriverCount.Text != "0")
    //    {
    //        int _noOfDriver = _CarPolicy.NoOfDriver;
    //        CarDriverList _cardriverlist = new CarDriverList();
    //        CarDriverDB _cardriverdb = new CarDriverDB();
    //        _cardriverlist = _cardriverdb.GetCarDriverList(_CarPolicy.CECarId, _CarPolicy.RefCEUserId);
    //        _cardriverdb = null;

    //        for (int i = 1; i <= _noOfDriver; i++)
    //        {
    //            CarDriver _cardriver = _cardriverlist[i - 1];
    //            if (i == 1)
    //            {
    //                UsrCarDriver1.DriverId = _cardriver.CarDriverId;
    //                UsrCarDriver1.Salutation = _cardriver.Salutation;
    //                UsrCarDriver1.SurName = Server.HtmlDecode(_cardriver.Surname);
    //                UsrCarDriver1.GivenName = Server.HtmlDecode(_cardriver.GivenName);
    //                UsrCarDriver1.Gender = _cardriver.Gender;
    //                UsrCarDriver1.DOB = _cardriver.DOB;
    //                UsrCarDriver1.IDType = _cardriver.IDType;
    //                UsrCarDriver1.IDNo = _cardriver.IDNo;
    //                UsrCarDriver1.IsEnabled = true;
    //                //UsrCarDriver1.SetProperty();
    //            }
    //            else if (i == 2)
    //            {
    //                UsrCarDriver2.DriverId = _cardriver.CarDriverId;
    //                UsrCarDriver2.Salutation = _cardriver.Salutation;
    //                UsrCarDriver2.SurName = Server.HtmlDecode(_cardriver.Surname);
    //                UsrCarDriver2.GivenName = Server.HtmlDecode(_cardriver.GivenName);
    //                UsrCarDriver2.Gender = _cardriver.Gender;
    //                UsrCarDriver2.DOB = _cardriver.DOB;
    //                UsrCarDriver2.IDType = _cardriver.IDType;
    //                UsrCarDriver2.IDNo = _cardriver.IDNo;
    //                UsrCarDriver2.IsEnabled = true;
    //                //UsrCarDriver2.SetProperty();
    //            }
    //            else if (i == 3)
    //            {
    //                UsrCarDriver3.DriverId = _cardriver.CarDriverId;
    //                UsrCarDriver3.Salutation = _cardriver.Salutation;
    //                UsrCarDriver3.SurName = Server.HtmlDecode(_cardriver.Surname);
    //                UsrCarDriver3.GivenName = Server.HtmlDecode(_cardriver.GivenName);
    //                UsrCarDriver3.Gender = _cardriver.Gender;
    //                UsrCarDriver3.DOB = _cardriver.DOB;
    //                UsrCarDriver3.IDType = _cardriver.IDType;
    //                UsrCarDriver3.IDNo = _cardriver.IDNo;
    //                UsrCarDriver3.IsEnabled = true;
    //                //UsrCarDriver3.SetProperty();
    //            }
    //            else if (i == 4)
    //            {
    //                UsrCarDriver4.DriverId = _cardriver.CarDriverId;
    //                UsrCarDriver4.Salutation = _cardriver.Salutation;
    //                UsrCarDriver4.SurName = Server.HtmlDecode(_cardriver.Surname);
    //                UsrCarDriver4.GivenName = Server.HtmlDecode(_cardriver.GivenName);
    //                UsrCarDriver4.Gender = _cardriver.Gender;
    //                UsrCarDriver4.DOB = _cardriver.DOB;
    //                UsrCarDriver4.IDType = _cardriver.IDType;
    //                UsrCarDriver4.IDNo = _cardriver.IDNo;
    //                UsrCarDriver4.IsEnabled = true;
    //                //UsrCarDriver4.SetProperty();
    //            }
    //            else if (i == 5)
    //            {
    //                UsrCarDriver5.DriverId = _cardriver.CarDriverId;
    //                UsrCarDriver5.Salutation = _cardriver.Salutation;
    //                UsrCarDriver5.SurName = Server.HtmlDecode(_cardriver.Surname);
    //                UsrCarDriver5.GivenName = Server.HtmlDecode(_cardriver.GivenName);
    //                UsrCarDriver5.Gender = _cardriver.Gender;
    //                UsrCarDriver5.DOB = _cardriver.DOB;
    //                UsrCarDriver5.IDType = _cardriver.IDType;
    //                UsrCarDriver5.IDNo = _cardriver.IDNo;
    //                UsrCarDriver5.IsEnabled = true;
    //                //UsrCarDriver5.SetProperty();
    //            }
    //        }
    //        _cardriverlist = null;
    //    }
    //}

    //private void DriverSetting()
    //{
    //    if (txtDriverCount.Text.Trim() != "0" )
    //    {
    //        int _drivercount = Convert.ToInt32(txtDriverCount.Text.Trim());

    //        for (int i = 1; i <= 5; i++)
    //        {
    //            string strCtrlName = "UsrCarDriver" + i.ToString();
    //            controls_usrCarDriverPersonal ctrlDriver = (controls_usrCarDriverPersonal)pnlDriver.FindControl(strCtrlName);
    //            if (ctrlDriver != null)
    //            {
    //                ctrlDriver.IsEnableValidation(false);
    //            }
    //        }

    //        for (int i = _drivercount; i >= 1; i--)
    //        {
    //            string strCtrlName = "UsrCarDriver" + i.ToString();
    //            controls_usrCarDriverPersonal ctrlDriver = (controls_usrCarDriverPersonal)pnlDriver.FindControl(strCtrlName);
    //            if (ctrlDriver != null)
    //            {
    //                ctrlDriver.IsEnableValidation(true);
    //            }
    //        }

    //    }
    //}

    private string[] GeneratePDFProposalForm(Int64 RefID)
    {
        string[] filelist = new string[1];

        HsbcCarInsurancePDFOutput GeneratePDF = new HsbcCarInsurancePDFOutput();

        string convertno = General.GetRefNumber(RefID);
        string _fileName = "H" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;

        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetHSBCProposalPDF(RefID, "CI");


        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            GeneratePDF.ClearFields();
            #region variables
            string _name, _dob, _nationality, _nric, _drvlicenceobtained, _maritalstatus, _mobile, _hoemphone, _officephone, _faxno, _unitno, _homeno, _address;
            string _postalcode, _gender, _empname, _email, _addidentdate, _natureofaccident, _claimamount, _typeofclaim, _revokedstatus;
            string _revokedyear, _revokedreason, _claimstatus, _dd, _mm, _yy, _occupation, _jobnature, _claim1ststat, _claim1stend, claimamt1;
            string _claimcount1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent, _inscomp;
            string _ncdreson, _vehicleno, _makemodel, _cc, _enginetype, _regyear, _offpeakcar, _bodytype, _purchaseprice, _engineno, _chassisno;
            string _insstartdate, _insenddate, _hp, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _drname1, _drdob1, _drdd1, _drmm1, _dryy1, _drocc1, _drnobus1;
            string _drname2, _drdob2, _drdd2, _drmm2, _dryy2, _drocc2, _drnobus2, _drname3, _drdob3, _drdd3, _drmm3, _dryy3, _drocc3, _drnobus3;
            string _drname4, _drdob4, _drdd4, _drmm4, _dryy4, _drocc4, _drnobus4, _drname5, _drdob5, _drdd5, _drmm5, _dryy5, _drocc5, _drnobus5;
            string _adddriver, _drcount, _installmenttype,  _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _planname, _covertype, _annualpremium;
            string _vehiclemodifystatus, _vehiclemodifyreason, _withoutcoeparf, _excess, _purposeofuse, _renewalncdpercent;

            string _dryearofobtained1, _drrelation1, _drrevokedstatus1, _drrevokedyear1, _drrevokedreason1, _drclaimstatus1;
            string _draccidentdate1, _drnatureofacc1, _drclaimamount1, _drtypeofclaim1;

            string _dryearofobtained2, _drrelation2, _drrevokedstatus2, _drrevokedyear2, _drrevokedreason2, _drclaimstatus2;
            string _draccidentdate2, _drnatureofacc2, _drclaimamount2, _drtypeofclaim2;

            string _isncdprotect, _cxcovertypeid;
            DateTime _dofb, _isdate, _iedate, _drdofb1, _drdofb2, _drdofb3, _drdofb4, _drdofb5, _hpcomname;
            _drname1 = "N/A"; _drdob1 = "N/A"; _drdd1 = ""; _drmm1 = ""; _dryy1 = ""; _drocc1 = ""; _drnobus1 = "";
            _drname2 = "N/A"; _drdob2 = "N/A"; _drdd2 = ""; _drmm2 = ""; _dryy2 = ""; _drocc2 = ""; _drnobus2 = "";
            _drname3 = ""; _drdob3 = "01/01/1900"; _drdd3 = ""; _drmm3 = ""; _dryy3 = ""; _drocc3 = ""; _drnobus3 = "";
            _drname4 = ""; _drdob4 = "01/01/1900"; _drdd4 = ""; _drmm4 = ""; _dryy4 = ""; _drocc4 = ""; _drnobus4 = "";
            _drname5 = ""; _drdob5 = "01/01/1900"; _drdd5 = ""; _drmm5 = ""; _dryy5 = ""; _drocc5 = ""; _drnobus5 = ""; _planname = ""; _annualpremium = "";
            _adddriver = ""; _drcount = "";_installmenttype="";  _nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";

            _revokedstatus = "No"; _revokedyear = "N/A"; _revokedreason = "N/A";
            _addidentdate = "N/A"; _natureofaccident = "N/A"; _claimamount = "N/A"; _typeofclaim = "N/A";

            _dryearofobtained1 = "N/A"; _drrelation1 = "N/A"; _drrevokedstatus1 = "No"; _drrevokedyear1 = "N/A"; _drrevokedreason1 = "N/A";
            _drclaimstatus1 = "No"; _draccidentdate1 = "N/A"; _drnatureofacc1 = "N/A"; _drclaimamount1 = "N/A"; _drtypeofclaim1 = "N/A";

            _dryearofobtained2 = "N/A"; _drrelation2 = "N/A"; _drrevokedstatus2 = "No"; _drrevokedyear2 = "N/A"; _drrevokedreason2 = "N/A";
            _drclaimstatus2 = "No"; _draccidentdate2 = "N/A"; _drnatureofacc2 = "N/A"; _drclaimamount2 = "N/A"; _drtypeofclaim2 = "N/A";

            _isncdprotect = ""; _cxcovertypeid = "";

            _name = _dsProposal.Tables[0].Rows[0]["FamilyName"].ToString() + " " + _dsProposal.Tables[0].Rows[0]["GivenName"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString().Substring(2, 2);
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _drvlicenceobtained = _dsProposal.Tables[0].Rows[0]["YearofObtained"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            //_email = CE.Security.MySecurity.Decrypt(_dsProposal.Tables[0].Rows[0]["Email"].ToString(), true);
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _jobnature = _dsProposal.Tables[0].Rows[0]["NofBusi"].ToString();
            _hoemphone = _dsProposal.Tables[0].Rows[0]["HomePhoneNo"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _faxno = _dsProposal.Tables[0].Rows[0]["FaxNo"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpName"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _covertype = _dsProposal.Tables[0].Rows[0]["ProviderCoverTypeDesc"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            _isncdprotect = _dsProposal.Tables[0].Rows[0]["Info4"].ToString();
            _cxcovertypeid = _dsProposal.Tables[0].Rows[0]["CXCoverTypeId"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
            }
            else
            {
                _claimstatus = "Yes";
            }

            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
                _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";
                _claimcount1 = "0";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";

                _ncdpercent = "0%";
            }

            if (_dsProposal.Tables[2].Rows.Count > 0)
            {
                _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();

                if (_inscomp.ToString() == "")
                {
                    _ncdstatus = "Not Applicable";
                }
                else
                {
                    _ncdstatus = "Yes";
                }
            }
            else
            {
                _ncdstatus = "No";
                _inscomp = "Not Applicable";
            }

            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
            if (_ncdreson.ToString() == "Others")
            {
                _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
            }
            else if (_ncdreson.ToString() == "-1")
            {
                _ncdreson = "Not Applicable";
            }

            _renewalncdpercent = _dsProposal.Tables[0].Rows[0]["RenewalNCDPercent"].ToString() + "%";
            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "10%";
            }
            else
            {
                if (_claimstatus == "No")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "0")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "1")
                {
                    _ncdpercent = OneTimesNCD(_ncdpercent);
                }
                else
                {
                    _ncdpercent = "0%";
                }
            }
            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _regyear = _dsProposal.Tables[0].Rows[0]["RegYear"].ToString();
            _makemodel = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _offpeakcar = _dsProposal.Tables[0].Rows[0]["Offbeak"].ToString();
            //if (Convert.ToBoolean(_dsProposal.Tables[0].Rows[0]["IsInsCOE"].ToString()) == false)
            //{
            //    _withoutcoeparf = "Yes";
            //}
            //else
            //{
            //    _withoutcoeparf = "No";
            //}
            if (_cxcovertypeid == "1" || _cxcovertypeid == "2") //WITH COE
            {
                _withoutcoeparf = "No";
            }
            else //5&6 WITHOUT COE
            {
                _withoutcoeparf = "Yes";
            }

            _excess = _dsProposal.Tables[0].Rows[0]["Excess"].ToString();
            _vehiclemodifystatus = _dsProposal.Tables[0].Rows[0]["VehclModify"].ToString();
            _vehiclemodifyreason = _dsProposal.Tables[0].Rows[0]["VechicleModifyReason"].ToString();
            _purposeofuse = _dsProposal.Tables[0].Rows[0]["OtherReason"].ToString();
            //if (_dsProposal.Tables[0].Rows[0]["PurposeofUse"].ToString() == "1")
            //{
            //    _purposeofuse = "Social Use";
            //}
            //else
            //{
            //    _purposeofuse = "Others";
            //}

            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _enginetype = _dsProposal.Tables[0].Rows[0]["EngineType"].ToString();
            _bodytype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _purchaseprice = _dsProposal.Tables[0].Rows[0]["PurchasePrice"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString().Substring(2, 2);
            _insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            //_insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString().Substring(2, 2);
            _insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            //_insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();
            if (Convert.ToBoolean(_dsProposal.Tables[0].Rows[0]["HasLicenceRevoked"].ToString()) == true)
            {
                _revokedstatus = "Yes";
                _revokedyear = _dsProposal.Tables[0].Rows[0]["YearofRevoked"].ToString();
                _revokedreason = _dsProposal.Tables[0].Rows[0]["RevokedReason"].ToString();
            }
            if (_dsProposal.Tables[6].Rows.Count > 0)
            {
                _addidentdate = _dsProposal.Tables[6].Rows[0]["AccidentDate"].ToString();
                _natureofaccident = _dsProposal.Tables[6].Rows[0]["NatureofAccident"].ToString();
                _claimamount = _dsProposal.Tables[6].Rows[0]["ClaimAmount"].ToString();
                _typeofclaim = _dsProposal.Tables[6].Rows[0]["TypeofClaim"].ToString();
            }

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hp.ToString() == "")
                {
                    _hp = "Not Applicable";
                }
            }
            else
            {
                _hp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "Yes";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "No";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drdofb1 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[0]["DOB"].ToString());
                    _drdd1 = _drdofb1.Day.ToString("00");
                    _drmm1 = _drdofb1.Month.ToString("00");
                    _dryy1 = _drdofb1.Year.ToString().Substring(2, 2);
                    //_drdob1 = _drdd1 + "/" + _drmm1 + "/" + _dryy1;
                    _drdob1 = _dsProposal.Tables[4].Rows[0]["DOB"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drnobus1 = _dsProposal.Tables[4].Rows[0]["DvrBusiness"].ToString();

                    _dryearofobtained1 = _dsProposal.Tables[4].Rows[0]["YearofObtained"].ToString();
                    _drrelation1 = _dsProposal.Tables[4].Rows[0]["RelationShip"].ToString();
                    if (_dsProposal.Tables[4].Rows[0]["RevokedStatus"].ToString() == "True")
                    {
                        _drrevokedstatus1 = "Yes";
                        _drrevokedyear1 = _dsProposal.Tables[4].Rows[0]["RevokedYear"].ToString();
                        _drrevokedreason1 = _dsProposal.Tables[4].Rows[0]["RevokedReason"].ToString();
                    }
                    if (_dsProposal.Tables[4].Rows[0]["ClaimStatus"].ToString() == "True")
                    {
                        _drclaimstatus1 = "Yes";
                        //DateTime _accdate1 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[0]["AccidentDate"].ToString());
                        //_draccidentdate1 = _accdate1.Day.ToString("00") + "/" + _accdate1.Month.ToString("00") + "/" + _accdate1.Year.ToString("0000");

                        string _draccidentdate1DD = _dsProposal.Tables[4].Rows[0]["AccidentDate"].ToString().Substring(0,2);
                        string _draccidentdate1MM = _dsProposal.Tables[4].Rows[0]["AccidentDate"].ToString().Substring(3,2); 
                        string _draccidentdate1YYYY = _dsProposal.Tables[4].Rows[0]["AccidentDate"].ToString().Substring(6,4);

                        _draccidentdate1 = _draccidentdate1DD + "/" + _draccidentdate1MM + "/" + _draccidentdate1YYYY;
                        _drnatureofacc1 = _dsProposal.Tables[4].Rows[0]["NatureofAccident"].ToString();
                        _drclaimamount1 = _dsProposal.Tables[4].Rows[0]["ClaimAmount"].ToString();
                        _drtypeofclaim1 = _dsProposal.Tables[4].Rows[0]["TypeofClaim"].ToString();
                    }
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drdofb2 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[1]["DOB"].ToString());
                    _drdd2 = _drdofb2.Day.ToString("00");
                    _drmm2 = _drdofb2.Month.ToString("00");
                    _dryy2 = _drdofb2.Year.ToString().Substring(2, 2);
                    //_drdob2 = _drdd2 + "/" + _drmm2 + "/" + _dryy2;
                    _drdob2 = _dsProposal.Tables[4].Rows[1]["DOB"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drnobus2 = _dsProposal.Tables[4].Rows[1]["DvrBusiness"].ToString();

                    _dryearofobtained2 = _dsProposal.Tables[4].Rows[1]["YearofObtained"].ToString();
                    _drrelation2 = _dsProposal.Tables[4].Rows[1]["RelationShip"].ToString();
                    if (_dsProposal.Tables[4].Rows[1]["RevokedStatus"].ToString() == "True")
                    {
                        _drrevokedstatus2 = "Yes";
                        _drrevokedyear2 = _dsProposal.Tables[4].Rows[1]["RevokedYear"].ToString();
                        _drrevokedreason2 = _dsProposal.Tables[4].Rows[1]["RevokedReason"].ToString();
                    }
                    if (_dsProposal.Tables[4].Rows[1]["ClaimStatus"].ToString() == "True")
                    {
                        _drclaimstatus2 = "Yes";
                        //DateTime _accdate2 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[1]["AccidentDate"].ToString());
                        //_draccidentdate2 = _accdate2.Day.ToString("00") + "/" + _accdate2.Month.ToString("00") + "/" + _accdate2.Year.ToString("0000");

                        string _draccidentdate2DD = _dsProposal.Tables[4].Rows[1]["AccidentDate"].ToString().Substring(0, 2);
                        string _draccidentdate2MM = _dsProposal.Tables[4].Rows[1]["AccidentDate"].ToString().Substring(3, 2);
                        string _draccidentdate2YYYY = _dsProposal.Tables[4].Rows[1]["AccidentDate"].ToString().Substring(6, 4);

                        _draccidentdate2 = _draccidentdate2DD + "/" + _draccidentdate2MM + "/" + _draccidentdate2YYYY;
                        _drnatureofacc2 = _dsProposal.Tables[4].Rows[1]["NatureofAccident"].ToString();
                        _drclaimamount2 = _dsProposal.Tables[4].Rows[1]["ClaimAmount"].ToString();
                        _drtypeofclaim2 = _dsProposal.Tables[4].Rows[1]["TypeofClaim"].ToString();
                    }
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drdofb3 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[2]["DOB"].ToString());
                    _drdd3 = _drdofb3.Day.ToString("00");
                    _drmm3 = _drdofb3.Month.ToString("00");
                    _dryy3 = _drdofb3.Year.ToString().Substring(2, 2);
                    //_drdob3 = _drdd3 + "/" + _drmm3 + "/" + _dryy3;
                    _drdob3 = _dsProposal.Tables[4].Rows[2]["DOB"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drnobus3 = _dsProposal.Tables[4].Rows[2]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drdofb4 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[3]["DOB"].ToString());
                    _drdd4 = _drdofb4.Day.ToString("00");
                    _drmm4 = _drdofb4.Month.ToString("00");
                    _dryy4 = _drdofb4.Year.ToString().Substring(2, 2);
                    //_drdob4 = _drdd4 + "/" + _drmm4 + "/" + _dryy4;
                    _drdob4 = _dsProposal.Tables[4].Rows[3]["DOB"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drnobus4 = _dsProposal.Tables[4].Rows[3]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drdofb5 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[4]["DOB"].ToString());
                    _drdd5 = _drdofb5.Day.ToString("00");
                    _drmm5 = _drdofb5.Month.ToString("00");
                    _dryy5 = _drdofb5.Year.ToString().Substring(2, 2);
                    //_drdob5 = _drdd5 + "/" + _drmm5 + "/" + _dryy5;
                    _drdob5 = _dsProposal.Tables[4].Rows[4]["DOB"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drnobus5 = _dsProposal.Tables[4].Rows[4]["DvrBusiness"].ToString();
                }
            }


            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefID, 23, "CI");
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();
                _installmenttype = _dsPayment.Tables[0].Rows[0]["Installment"].ToString();
                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }
            #endregion


            GeneratePDF.QuotationNo = "H" + convertno;
            GeneratePDF.ApplicationDate = CE.Global.General.GetUTCDateTime();
            GeneratePDF.CustomerName = _name;
            GeneratePDF.CustomerDOB = _dob;
            GeneratePDF.Nationality = _nationality;
            GeneratePDF.CustomerAddress = _address;
            GeneratePDF.CustomerUnitNo = _unitno;
            GeneratePDF.CustomerHomeNo = _homeno;
            GeneratePDF.CustomerPostCode = _postalcode;
            GeneratePDF.NRIC = _nric;
            GeneratePDF.DrvLicenceObtained = _drvlicenceobtained;
            GeneratePDF.CustomerMaritalStatus = _maritalstatus;
            GeneratePDF.CustomerGender = _gender;
            GeneratePDF.CustomerOccupation = _occupation;
            GeneratePDF.CustomerJobNature = _jobnature;
            GeneratePDF.MobileNo = _mobile;
            GeneratePDF.OfficeNo = _officephone;
            GeneratePDF.HomePhoneNo = _hoemphone;
            GeneratePDF.FaxNo = _faxno;
            GeneratePDF.EmployersName = _empname;
            GeneratePDF.EmailAddress = _email;

            GeneratePDF.AccidentDate = _addidentdate;
            GeneratePDF.NatureofAccident = _natureofaccident;
            GeneratePDF.ClaimAmount = _claimamount;
            GeneratePDF.TypeofClaim = _typeofclaim;

            GeneratePDF.IsRevoked = _revokedstatus;
            GeneratePDF.RevokedYear = _revokedyear;
            GeneratePDF.RevokedReason = _revokedreason;
            GeneratePDF.IsNCD = _ncdstatus;

            GeneratePDF.Driver1Name = _drname1;
            GeneratePDF.Driver1DOB = _drdob1;
            if (_drocc1 == "" && _drnobus1 == "")
            {
                GeneratePDF.Driver1Occupation = "N/A";
            }
            else
            {
                GeneratePDF.Driver1Occupation = _drocc1 + " / " + _drnobus1;
            }
            //GeneratePDF.Driver1Occupation = _drocc1;
            GeneratePDF.Driver1JobNature = _drnobus1;

            GeneratePDF.Driver1LicenceObtained = _dryearofobtained1;
            GeneratePDF.Driver1RelationshipToProposer = _drrelation1;
            GeneratePDF.Driver1IsRevoked = _drrevokedstatus1;
            GeneratePDF.Driver1RevokedYear = _drrevokedyear1;
            GeneratePDF.Driver1RevokedReason = _drrevokedreason1;
            GeneratePDF.Driver1IsFaultClaim = _drclaimstatus1;

            GeneratePDF.Driver1AccidentDate = _draccidentdate1;
            GeneratePDF.Driver1NatureofAccident = _drnatureofacc1;
            GeneratePDF.Driver1ClaimAmount = _drclaimamount1;
            GeneratePDF.Driver1TypeofClaim = _drtypeofclaim1;

            GeneratePDF.Driver2Name = _drname2;
            GeneratePDF.Driver2DOB = _drdob2;
            if (_drocc2 == "" && _drnobus2 == "")
            {
                GeneratePDF.Driver2Occupation = "N/A";
            }
            else
            {
                GeneratePDF.Driver2Occupation = _drocc2 + " / " + _drnobus2;
            }
            //GeneratePDF.Driver2Occupation = _drocc2;
            GeneratePDF.Driver2JobNature = _drnobus2;

            GeneratePDF.Driver2LicenceObtained = _dryearofobtained2;
            GeneratePDF.Driver2RelationshipToProposer = _drrelation2;
            GeneratePDF.Driver2IsRevoked = _drrevokedstatus2;
            GeneratePDF.Driver2RevokedYear = _drrevokedyear2;
            GeneratePDF.Driver2RevokedReason = _drrevokedreason2;
            GeneratePDF.Driver2IsFaultClaim = _drclaimstatus2;

            GeneratePDF.Driver2AccidentDate = _draccidentdate2;
            GeneratePDF.Driver2NatureofAccident = _drnatureofacc2;
            GeneratePDF.Driver2ClaimAmount = _drclaimamount2;
            GeneratePDF.Driver2TypeofClaim = _drtypeofclaim2;

            GeneratePDF.Driver3Name = _drname3;
            GeneratePDF.Driver3DOB = _drdob3;
            GeneratePDF.Driver3Occupation = _drocc3;
            GeneratePDF.Driver3JobNature = _drnobus3;

            GeneratePDF.Driver3AccidentDate = "CX_Data..";
            GeneratePDF.Driver3NatureofAccident = "CX_Data..";
            GeneratePDF.Driver3ClaimAmount = "CX_Data..";
            GeneratePDF.Driver3TypeofClaim = "CX_Data..";

            GeneratePDF.Driver4Name = _drname4;
            GeneratePDF.Driver4DOB = _drdob4;
            GeneratePDF.Driver4Occupation = _drocc4;
            GeneratePDF.Driver4JobNature = _drnobus4;

            GeneratePDF.Driver5Name = _drname5;
            GeneratePDF.Driver5DOB = _drdob5;
            GeneratePDF.Driver5Occupation = _drocc5;
            GeneratePDF.Driver5JobNature = _drnobus5;

            GeneratePDF.VehicleNo = _vehicleno;
            GeneratePDF.ChassisNo = _chassisno;
            GeneratePDF.EngineNo = _engineno;
            GeneratePDF.BodyType = _bodytype;
            GeneratePDF.CarMake = _makemodel;
            GeneratePDF.EngineType = _enginetype;

            GeneratePDF.YearOfRegistration = int.Parse(_regyear);
            GeneratePDF.CarSeaters = 0;
            GeneratePDF.CarCC = int.Parse(_cc);
            GeneratePDF.OffPeakCar = _offpeakcar;
            GeneratePDF.WithOutCOEPARF = _withoutcoeparf;
            if (_purchaseprice.ToString() != "0")
            {
                GeneratePDF.PurchasePrice = "S$" + string.Format("{0:0,0.00}", Convert.ToDouble(_purchaseprice));
            }
            else
            {
                GeneratePDF.PurchasePrice = "Not Applicable";
            }

            GeneratePDF.CurrentInsuranceCo = _inscomp;
            GeneratePDF.Last3YearsClaimXP = _claimstatus;
            GeneratePDF.NoClaimsLast3Years = _claimcount1;

            //if (_ncdexisting == "-1")
            GeneratePDF.NCDPercent = _renewalncdpercent;
            //else
            //    GeneratePDF.NCDPercent = _ncdexisting;
            GeneratePDF.CurrentInsuranceCo = _inscomp;
            GeneratePDF.NCDNilDetails = _ncdreson;
            GeneratePDF.IsCarModified = _vehiclemodifystatus;
            GeneratePDF.ModifiedReason = _vehiclemodifyreason;
            GeneratePDF.FinanceCo = _issuebank;
            GeneratePDF.HPCompanyName = _hp;
            GeneratePDF.InsStartDate = _insstartdate;
            GeneratePDF.InsEndDate = _insenddate;
            GeneratePDF.TypeOfCover = _covertype;
            GeneratePDF.PurposeOfUse = _purposeofuse;
            GeneratePDF.DemeritPointsReason = "";
            GeneratePDF.TotalPremium = string.Format("{0:0,0.00}", Convert.ToDouble(_annualpremium));
            GeneratePDF.OwnDamageExcess = _excess;
            //GeneratePDF.NCDProtector = "No";
            GeneratePDF.NCDProtector = _isncdprotect;
            GeneratePDF.IssuingBank = _issuebank;
            GeneratePDF.CardType = _cctype;
            GeneratePDF.CardNo = _ccno;
            //GeneratePDF.CardExpiryMonth = Convert.ToDateTime("1-" + _ccexmm + "-" + _ccexyy);
            GeneratePDF.CardholdersName = _nameofcard;
            GeneratePDF.InstallmentType = _installmenttype;
            GeneratePDF.HsbcPDFProposalForm(_fileName);

            //SEND MAIL
            //string _providerEmail = "cherylmae.lanot@teledirect.com.sg"; // CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_TO");
            //string _providerCCEmail = ""; //CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_CC");
            //string _providerBCCEmail = ""; // CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_BCC");

            string _filePath = GeneratePDF.GetFilePathHsbc();
            string _pdffile = _filePath + _fileName + ".pdf";

            //string _pdffile = Server.MapPath("/pdfoutput/" + _fileName + ".pdf");
            filelist[0] = _pdffile;


            //string _refid = "L" + convertno;
            //MyMailManager.SendCarProposalAttachment("Liberty Insurance", _providerEmail, _providerCCEmail, _providerBCCEmail, "", CE.Global.General.GetUTCDateTime().ToShortDateString(), CE.Global.General.GetUTCDateTime().ToShortTimeString(), _refid, "Liberty", filelist);

        }

        return filelist;

    }

    public string GetFilePathHsbc()
    {
        string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
        _filePath += "pdfoutput\\hsbc\\";
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        string _todaydate = CE.Global.General.GetUTCDateTime().ToString("yyyyMMMdd");
        if (!_myIO.CheckDirectory(_filePath + _todaydate))
        {
            if (_myIO.CreateDirectory(_filePath, _todaydate))
            {
                _filePath += _todaydate + "\\";
            }
        }
        else
        {
            _filePath += _todaydate + "\\";
        }

        return _filePath;
    }

    protected void GetNCDProtection()
    {
        if (inputNCD.Value == "50")
        {
            lblPremiumBeforeNCDPro.Text = lblPremiums.Text;

            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable();

            string _spName = "[sprocCarInsuranceTempResultSelectItemSelectSingleItem]";
            SortedList _sPara = new SortedList();
            _sPara.Add("@CECarId", _CarId);
            _sPara.Add("@CarResultId", _CXCTypeId);
            _sPara.Add("@RefCEUserId", _UserId);
            _sPara.Add("@ProviderCompanyId", _ProviderId);

            _dtResult = _db.GetDataTableBySP(_spName, _sPara);

            if (_dtResult.Rows.Count > 0)
            {
                lblPremiumAfterNCDPro.Text = String.Format("${0:f}", float.Parse(_dtResult.Rows[0]["Finfo1"].ToString()));
                lblPremiumAfterNCDProNoFormat.Text = String.Format("{0:f}", float.Parse(_dtResult.Rows[0]["Finfo1"].ToString()));
            }
        }
    }

}
